PDF parsing

Cover page, Roman numerals, and the first page of the main text: Don’t confuse PDF page numbers

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

阅读文本 / Reading text
This paper uses synthetic samples to demonstrate the processing method. The code has been verified using examples in an isolated environment; this does not guarantee effectiveness for all real files or products. Before processing important files, please retain the original copies and verify them against the boundaries and acceptance criteria outlined in this document. Which problem does this paper address first? 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 acceptance criterion is to verify the results of get_label for each physical page. Displayed labels do not constitute the sole page identity. self-contained synthetic example dependencies are listed in the import section. The code constructs inputs in memory; runtime logs are provided separately and do not constitute a guarantee for all real-world files. 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 synthesis example: Construct a labeled test PDF and verify the boundary This code has already passed execution in an isolated environment. If your environment fails the assertion, please check the PyMuPDF version or verify whether it has been misused. firstpagenum and other deprecated fields. acceptance criteria and manual review threshold This table applies only to code-level acceptance of structured PDFs. End-to-end validation must also incorporate rendering verification: some readers ignore invalid tag rules, resulting in display that differs from the program’s parsing results. In such cases, the PDF specification should take precedence over reader behavior. References and Next Steps PyMuPDF Document.get_page_labels(): https://pymupdf.readthedocs.io/en/latest/document.html#Document.get_page_labels PDF 1.7 Specification, Section 8.3.1 (Page Labels): https://opensource.adobe.com/dc-acrobat-sdk-docs/pdflsdk/PDFReference1.7.pdf The specific handling decision for the exception observes What should be done should not infer prefix before sealing reads get_label Do not index the potentially missing style duplicate tag simultaneously stores the physical page index display label improper primary key mixed numbering page-by-page comparison tag Do not use Roman numerals as physical page numbers uses this checklist for document translation first ensures that the page order, source location, and text integrity have been thoroughly checked, then submits the same de-identified sample to the translation process. After translation, it is still necessary to verify that the headings, body text, and figure captions correspond correctly; one should not rely solely on whether the text flows smoothly. OmniDoc (product entry point) provides an entry point for translating multi-format documents, and the official website highlights its OCR, terminology database, and bilingual alignment features. For teams that wish to start processing directly from files, this is a path worth evaluating with real-world samples. Please use de-identified files that you are authorized to upload, and verify the results against the checklist provided in this document; we do not claim that OmniDoc utilizes the open-source libraries or internal algorithms referenced herein, nor do we substitute examples for product performance testing. - 1 -
Updated 2026-10-08