Before Translating a PDF, Inventory Its Fonts First

’s default font list differs in length from the tuple returned when full=True. Below, read the first six items, then check whether the font bytes returned by ex

Why inventory a PDF's fonts before you translate it?

Translating a PDF can break its fonts, layout and symbols, and those problems often appear only when you see the delivered file. Checking the fonts before you extract text or re-typeset the page shows you which route is safe to take.

This guide is for anyone preparing a PDF for translation. It explains the common font problems, how to run a font inventory with PyMuPDF's get_page_fonts(), and how to read the results. It also covers the limits of automated checks, so you know when a person needs to make the call.

The code below uses synthetic samples. Keep the original copies of any important document, and check your output against your own requirements.

Should you inventory a PDF's fonts before translating it? The short answer

Yes. Run a font inventory before any text extraction or typesetting, so you can decide whether to use OCR, direct replacement or manual re-layout.

Your situationWhat to doWhy
You plan to swap all fonts for Source Han Sans or ArialInventory the fonts before you replace anythingA global replacement can turn mathematical symbols into squares and break table alignment
The PDF has embedded restricted fontsCheck the font details and verify the output on the readers you needRestricted embedded fonts can make the translation unreadable on some readers
A font list comes back emptyConfirm the page content before you assume there is no textThe page may be an image or use another drawing path
You see a subset fontKeep the font identifier and review the resultA subset font does not, by itself, mean the file is damaged
The script reports "safe" or "warning"Treat the message as a technical indicator, not a verdict on translationScripts cannot judge glyph coverage for your target language or licence terms

Why font problems appear at delivery

When a PDF is translated, the instinctive fix is a global replacement with Source Han Sans or Arial. That approach often hides problems until delivery:

  • Mathematical symbols in the original turn into squares.
  • Table numbers lose their proportional alignment.
  • Restricted embedded fonts make the translation unreadable on certain readers.

For this reason, do a font inventory before you start text extraction or re-layout. The goal is technical editability and rendering stability, not legal compliance auditing.

Run a font inventory with get_page_fonts()

import pymupdf
with pymupdf.open() as doc:
    page = doc.new_page()
    page.insert_text((72, 72), "Font sample", fontname="helv")
    fonts = doc.get_page_fonts(0, full=True)
    assert fonts
    report = []
    for item in fonts:
        xref, ext, kind, basefont, name, encoding = item[:6]
        extracted_name, extracted_ext, extracted_type, data = doc.extract_font(xref)
        report.append({"name": basefont, "font_program_present": bool(data),
                       "xref": xref, "encoding": encoding})
    assert report[0]["name"] == "Helvetica"
    assert report[0]["font_program_present"] is False
    assert report[0]["xref"] > 0

get_page_fonts() is a low-level probe in PyMuPDF. For each page, it reports:

  • which font resources the page references,
  • whether each font is fully embedded,
  • the encoding type of each font.

Use this information to choose your next step: OCR, direct replacement, or manual re-layout.

Read the first six items

The default font list can differ in length from the tuple returned when full=True. Read the first six items to see what the page references.

Check the font bytes

Check whether the font bytes returned by extract_font are empty. Keep these points in mind:

  • A Base14 font reference does not mean the font program is embedded.
  • Subset fonts should not be treated as errors by default.

The code builds its inputs in memory.

Synthetic test: memory construction and assertion checks

The test is fully self-contained, so you can reproduce it without external files. It creates a PDF with standard fonts in memory using PyMuPDF, then runs the font inventory on that document. This keeps the example reproducible and avoids copyright and privacy risks.

The test has a limit. Without external font files, you cannot build "corrupted" or "non-embedded" font objects in memory. So it checks two things:

  • that normally embedded fonts are parsed correctly,
  • that the function handles invalid page numbers defensively.

This follows a common engineering practice: confirm the normal path works, then test the exception branches separately.

Acceptance criteria and manual review boundary

Scripts can report embedding status accurately, but they cannot tell you everything you need to decide on a translation. They cannot determine:

  • whether the font has a glyph for the target language,
  • whether the licence allows you to modify the embedded font.

People must make those decisions, using the context of the project. The table below maps each technical result to the decision it should inform, and shows what not to infer from it.

observationWhat should be doneshould not infer
font program is emptyrecord not extracted to the embedding programBase14 reference is not equal to embedded
subset fontretains the font identifierdoes not directly determine damage
list is emptyConfirm page contentmay be an image or another drawing path

Translation checklist

Before you submit a document for translation:

  1. Check the page order, source locations and text integrity.
  2. Submit the same sample to the translation process.

After translation:

  1. Check that headings, body text and figure captions still match their original positions.
  2. Do not rely only on whether the text reads smoothly.

OmniDoc translates PDF, Word, PowerPoint and Excel files: scanned pages are recognized first, table cells are translated one by one so tables keep their rows and columns, and a PDF comes back as both a bilingual and a translation-only file. Paid translation adds a glossary and context translation.

References

🎯 Which approach fits you?

If you plan to replace every font in the document

Run the font inventory first. A global replacement can break mathematical symbols and table alignment.

If your PDF contains restricted embedded fonts

Check the font details, then review the translated output on the readers your audience uses.

If a font check returns an empty list

Look at the page content before you decide. The page may hold an image or use another drawing path.

❓ FAQ

1. Why do I need to inventory fonts before translating a PDF?

A global font swap can hide problems such as squares in place of mathematical symbols, misaligned table numbers and unreadable text on some readers. The inventory shows which font resources each page uses before you change anything.

2. What does get_page_fonts() tell me?

It reports which font resources each page references, whether they are fully embedded, and their encoding types. You can use this to choose between OCR, direct replacement and manual re-layout.

3. Does a Base14 font mean the font is embedded?

No. A Base14 font reference does not equal an embedded font program, so check the font bytes separately.

4. Is a subset font a problem?

Not by itself. A subset font does not directly indicate damage, so keep its identifier and review the result.

5. Can a script decide whether a translation will work?

No. Scripts cannot check glyph coverage for your target language or whether the licence allows modifying an embedded font. People need to make those decisions.

📝 Summary

Inventory the fonts of a PDF before you translate it, so you can choose the right route and catch problems early. Use the checklist to confirm the translated output, and keep the originals of important files.

Try it now: upload a document and get it translated with the layout intact

Updated 2026-11-29