Cover, Roman Numerals, Page 1: Don't Mix Up PDF Page Labels

page-numbering tag rules use firstpagenum, not start. When the cover page has only a prefix, the read-back rule dictionary may omit style; a more meaningful acc

Page labels in a PDF don't always match the physical pages they describe. A cover page with only a prefix, Roman-numeral front matter, or a page 1 that restarts the count can all make a label look right while pointing to the wrong page. This guide is for developers and document teams who process structured PDFs and need page identity to hold up under automation.

The guide explains which tag rules to use, how to check labels against physical pages, and what to verify before you trust the output. It also includes a short example that builds a labeled test PDF, so you can see the behaviour before you run anything on real files.

They do not guarantee results for every real file or product. Keep the original copies of any important files, and check your results against the criteria described below.

How do you handle cover and Roman-numeral page labels in a PDF? The short answer

Read each physical page with get_label, and key your records on the physical page index rather than the label shown to readers.

Your situationWhat to doWhy
Page-numbering tag rules are being setUse firstpagenum, not startThe tag rules use firstpagenum
The cover page has only a prefixRead the labels with get_labelThe read-back rule dictionary may omit style, so don't index on it
Labels are duplicatedStore the physical page index alongside each recordA display label is not a reliable primary key
Roman and Arabic numbering are mixedCompare the tags page by pageRoman numerals are not physical page numbers
You are preparing a document for translationCheck page order, source location and text integrity before submittingVerification after translation confirms the headings, body text and captions still match

Why page labels need careful handling

Page labels are a display feature. A reader might show "iii" on the third physical page or "1" on the page after a cover, but the file's physical order is still the real structure. If your code uses the displayed label as a key, you can end up with records that point to the wrong page.

Keep these points in mind:

  • Labels are not identity. A displayed label does not identify a page on its own.
  • Prefixes and styles can be incomplete. When the cover page has only a prefix, the rule dictionary read back may leave out style.
  • Readers differ. Some readers ignore invalid tag rules, so what you see may not match what your program parses.

Set up the example

The example uses a self-contained setup. Dependencies are listed in the import section, and the code builds its inputs in memory, so you don't need external files to run it.

import pymupdf
with pymupdf.open() as source:
    for _ in range(4):
        source.new_page()
    source.set_page_labels([
        {"startpage": 0, "prefix": "Cover", "style": "", "firstpagenum": 1},
        {"startpage": 1, "prefix": "", "style": "r", "firstpagenum": 1},
        {"startpage": 3, "prefix": "", "style": "D", "firstpagenum": 1},
    ])
    raw = source.tobytes()
with pymupdf.open(stream=raw, filetype="pdf") as doc:
    assert [page.get_label() for page in doc] == ["Cover", "i", "ii", "1"]
    assert len(doc.get_page_labels()) == 3
    assert doc.get_page_labels()[0].get("style", "") == ""
    assert doc.page_count == 4

Build a labeled test PDF and check the boundary

If the assertion fails in your environment, work through these checks:

  1. Confirm the PyMuPDF version you are running.
  2. Check whether deprecated fields such as firstpagenum have been misused in your rule setup.
  3. Re-run the check on the test PDF before you try real files.

Acceptance criteria and manual review

These criteria apply to code-level acceptance of structured PDFs. They are not the whole picture.

  • Code checks are not enough on their own. End-to-end validation also needs rendering verification.
  • Readers can disagree. Some readers ignore invalid tag rules, so the displayed result can differ from what your program parses.
  • The specification comes before reader behaviour. When a reader behaves differently from the PDF specification, follow the specification.

Handling exceptions

Use this table when you find an unusual page-label situation:

ObservationWhat to doWhat not to infer
A prefix appears before the sealed numberingRead the labels with get_labelDon't index on the style, which may be missing
Duplicate labels appearStore the physical page index at the same timeDon't treat the display label as the primary key
Numbering is mixedCompare the tags page by pageDon't treat Roman numerals as physical page numbers

If your numbering has a prefix on the cover

Read every label with get_label, and don't rely on a style value being present in the rule dictionary.

If you see duplicate labels

Keep the physical page index in every record, and use it to link results back to the file.

If your document mixes Roman and Arabic numerals

Compare the tags for each physical page, and don't use the Roman numerals as page positions.

Using this checklist for document translation

Apply the same checks when you prepare a document for translation:

  1. Confirm the page order, source location and text integrity before you submit anything.
  2. Submit a real sample before the full file, so you can check the process on a small document.
  3. After translation, verify that headings, body text and figure captions still correspond correctly.
  4. Don't judge the result by how smoothly the text reads. A fluent translation can still sit in the wrong place.

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 and next steps

🎯 Which approach fits you?

If your cover page has only a prefix

Read the labels with get_label, and check each physical page rather than trusting the rule dictionary.

If you process documents that repeat page labels

Store the physical page index with every record, so the display label is never the only link.

If your document is headed for translation

Verify page order and text integrity before you submit it, and check headings, body text and captions afterwards.

❓ FAQ

1. Should I use start or firstpagenum in page-numbering tag rules?

Use firstpagenum. The tag rules use firstpagenum, not start.

2. Why can't I rely on the label a reader displays?

A displayed label is not a page's identity on its own, and some readers ignore invalid tag rules. Keep the physical page index with each record.

3. What should I do if the read-back rule dictionary is missing the style?

Read each label with get_label, and don't index on a style value that may be absent.

4. Are the code examples enough to validate my files?

No. Add rendering verification to your end-to-end checks.

5. Can I use OmniDoc for translation with the same checks?

📝 Summary

Page labels are useful for readers, but your code should track pages by their physical position. Use firstpagenum, check labels with get_label, and verify the output with rendering checks as well as code.

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

Updated 2026-11-29