Repository navigation
Conversation
…ode space Adobe's tools write <0000> <FFFF> as the ToUnicode code space of one-byte fonts; strings were read as two-byte codes with no mapping and dropped. Audit 2a C1.
… binds A PDF stream passes a 2 GB limit, so every content stream got a zeroed slab of input x 1032 plus a megabyte (8 MB for a 5 KB page). A loose limit now starts a few times the input and doubles, and growth has no megabyte floor. A 1,390-page PDF to text: 1.64 s and 234 MB -> 0.94 s and 23 MB, text identical. Audit 5 H1.
The span's text sits on its first glyph, which now reaches to the end of the span's last glyph; a word gap is measured from the furthest a line has reached, so a combining mark set back over its letter opens none. Audit 2a H1.
… encoding pdfTeX's CMSY10 carries neither /Encoding nor ToUnicode; its bullets and arrows are named only in the embedded program. The Type 1 clear-text /Encoding array and a Type 1C program's encoding and charset (with the CFF standard strings) now give the base encoding. Audit 2a H2.
…mmon drop The line spacing a block joins at is the smallest drop that happens twice, not the most common one (on a page of short paragraphs that is the paragraph spacing). A line inside a block that starts a list item starts a block of its own; a lone bold character is no heading; blank blocks make no empty paragraph. Audit 2a H4.
A row taller than a page breaks across pages between its lines; a table whose longest words do not fit side by side gives each column a character's width and a share of the rest, breaking words by characters; one with more columns than that fits is set as lines of text, cells between bars. Audit 2a H5 and H6.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes from the November 2026 audit (reports
2a-pdf-correctnessand5-performance-memory): PDF reading, inflate memory, and tables in the PDF writer.Fixes
<0000> <FFFF>there. Adobe's sample PDFs went from losing 40 to 97% of their words to matching pdftotext word for word.tests/fixtures/pdf-text/adobe-codespace.pdf, checked against pdftotext bytests/pdf_text.rsinflate()sizes its slab for the worst ratio only when the limit binds (a ZIP entry's size). With a loose limit (a PDF stream's 2 GB) it starts at 6x the input and doubles. The 1 MB growth floor is gone.deflate::inflate::tests::loose_limit_starts_small(fails on main: a 2.2 MB slab for 138 KB)/ActualTextover several glyphs: the glyph that carries the text now reaches to the end of the span, unless the replacement is a tab or other blank. A word gap is measured from the furthest point the line has reached, so a combining mark set back over its letter opens no gap.tests/fixtures/pdf-text/actualtext-ligature.pdf;pdf::text::tests::a_mark_set_back_opens_no_gap/Encoding(or whose/Encodinghas no/BaseEncoding) uses the encoding built into its embedded program: the Type 1 clear-text/Encodingarray, or the CFF encoding and charset for Type 1C. A newcff::encoding_namesreads the latter, with the 391 CFF standard strings.tests/fixtures/pdf-text/builtin-encoding.pdf(hand-built CMSY10 with bullets and arrows, against pdftotext);font::tests::a_type1_program_names_its_codes;cff::tests::a_custom_encoding_names_its_codespdf::text::tests::paragraph_spacing_parts_short_paragraphs;pdf::markdown::tests::items_inside_a_block_start_their_own;tests/pdf_markdown.rs::bullets_from_a_built_in_encoding_make_a_listtests/to_pdf.rs::tables_stay_on_the_page(1,500-word cell; 14 columns plus a 120-character word; 40 columns: every line inside the margins, every character present)Verification
All text outputs were compared against pdftotext, before and after each step, on 445 PDFs: every repo fixture, the audit's repros, its generated LibreOffice/Chrome/Ghostscript files, 54 system PDFs, and the pdf.js corpus.
gs-lig-hoefler.pdfscores lower only because pdftotext's own output on that file is garbled. Ours now reads the ligature words correctly.vbox-manual.pdfgoes from 1,809 missing words to 482. The rest is pre-existing uppercase hyphen joining.lo-lists, Chrome's nested list, the Apple licences,xcode-ack, tracemonkey, a form).Item 2 timing (
big.pdf, the audit's 1,390-page, 9.1 MB PDF, to text, median of 5,/usr/bin/time -l)Text output is byte-identical. The machine was loaded (load average around 28), so absolute times are noisy, but the ratio held on every run. Other inflate callers are unchanged (medians, outputs identical):
Checks
cargo test --all-targets: all pass.cargo fmt --check: clean.check-formats-doc.sh,cargo doc: OK.cargo clippy --all-targets -D warnings: no findings in changed files. The local toolchain (1.100) reports 15 findings in untouched files (hevc, pages writer, rtf reader, planner) that are also on main.