🌀 Release fingerprint — v0.11.2..v0.12.0
4 commits · 1 contributor(s) · +3000/-23 across 21 files · 2026-10-08 → 2026-12-01
🎨 Generated from this release's commit signal — how it's made →
A page whose text is drawn as filled outlines, as Microsoft Print to PDF writes it, can now be read once its shapes are named. A PDF of a few hundred bytes can no longer hang the parser or exhaust its memory. Reading a page no longer decodes the images it draws.
Text drawn as outlines
Page.OutlineHint already said when an empty page may be text drawn as outlines. Document.Outlines now reads such pages. A document repeats a few hundred shapes, and gopdf never says what they spell, so the caller names each one once. NamingSheet draws them in numbered cells, for a vision model or a person to name:
outlines, err := doc.Outlines() // ErrNoOutlines when no page looks outlined
sheet, err := outlines.NamingSheet(1) // a PDF to name the shapes from
names := map[int]string{0: "e", 1: "ll"} // one character, or the few one fill merged
texts, err := outlines.Text(names) // a text per page of outlines.Pages()The same from the command line:
gopdf outlines sheet printed.pdf -o sheet.pdf
gopdf outlines text printed.pdf -names '{"0": "e", "1": "ll"}'
- Every named glyph is placed. A digit in a column of its own stays on its row, and a date apart from all other text stays in one piece.
- The case of c, o, s, v, w, x and z is settled by height, as their capitals are the same outline enlarged.
- The bars that l, I and | share are settled by the letters around them, which is a guess.
- The naming sheet can draw every shape several times, each time among other neighbours, so that several namings can be compared.
On two files printed through Microsoft Print to PDF (67 pages, 71,173 glyphs, 435 shapes) a vision model named the shapes three times. With the majority taken, 7 of 13,830 words differ from names given by hand.
It is experimental. The placement and spacing rules were measured on that one producer.
Fixes that change existing behaviour
- A stray
),{or}is an error, as a stray>already was. It used to hang the parser or exhaust its memory, and a PDF of a few hundred bytes was enough (#42). - Nesting is bounded at 1000 levels.
ParseObjectreturns an error past it. Stream.Dataof an image is what the file holds, as it already was for DCTDecode. Reading a page used to decode every image it draws, though nothing reads the pixels. 40 made-up A4 scans at 300 dpi took 1.4 GB, and now take 31 MB. A caller that read the pixels of a Flate image throughResolvehas to decode them itself.
No exported library symbols were removed.
Full changelog: v0.11.2...v0.12.0
