Skip to content

M4.86–M4.87: PDF thumbnails, fast web view and PDF 1.3 (M4 done) - #124

Merged
bflatastic merged 2 commits into
mainfrom
pr/m4-pdf-thumbs-linearize-13
Oct 5, 2026
Merged

bflatastic merged 2 commits into
mainfrom
pr/m4-pdf-thumbs-linearize-13

Conversation

@bflatastic

Copy link
Copy Markdown
Member

PDF page thumbnails, fast web view (linearised files) and PDF 1.3 compatibility. This is the last M4 package; the ROADMAP now marks M4 done.

M4.86: thumbnails and fast web view

  • thumbnails: true gives every page a /Thumb image, 106 px on its long side. PDF/X files get grey thumbnails, so X-1a stays CMYK-only.
  • fastWebView: true writes a linearised file (pdf/src/linearize.rs, run from the post-write pipeline in post.rs).
    • Objects are reordered and renumbered before encryption and laid out after it, so encrypted files stay linearised.
    • If linearising fails, the file is written without it and a warning says so.
    • qpdf's linearisation check passed by hand on plain files and on 40-bit RC4, 128-bit RC4, AES-128 and AES-256 encrypted files. A hint-table checker in the tests catches wrong shared-object ids.
  • With both options off, the output is byte-identical to before. Their "not embedded / not written yet" warnings are gone.

M4.87: PDF 1.3

  • compatibility: "1.3" flattens a copy of the document with flattenerPreset (High Resolution by default; PDF presets store it).
    • Rasterised areas are clipped to their regions, so no soft masks remain.
    • The header and XMP say 1.3, and the writer refuses a file that still has transparency.
  • Passwords at 1.3 use 40-bit RC4, the only encryption PDF 1.3 has.
  • PDF/X-1a and X-3 now accept and default to 1.3. They share the 1.3 header code with this task, and they also take flattenerPreset (default unchanged).
  • The Save PDF dialog lists PDF 1.3 and gains a Flattener preset dropdown.
  • A test imports a 1.3 file, renders it, and checks it is within 2% of the canvas.

ROADMAP and README

  • M4 is marked ✅ done. Still left: DWG (use DXF), placing PSDs as layers, overprint read back from PDF, and polish.
  • "Flattener presets not applied in PDF/print" is removed from the M3, Appearance and Print rows.
  • README: the status line lists the M4 formats, and the workspace list gains eps, cad and metafile.

Checks

  • Rebased on main at 87df4a0 (M4.82–M4.83: PDF layers and overprint #123).
  • cargo xtask ci passes all 7 steps (fmt, clippy, tests, assets, brands, layers, wasm), with 2,921 tests.
  • Nothing dropped: compared with main, every test (2899 → 2914 by name), engine command, UI command, menu entry and MCP tool is still there.
  • Tests changed because 1.3, thumbnails and fast web view now work:
    • pdf tests_settings: the camel-case test's bad version is now "1.2", and the warnings test no longer expects the thumbnails and fast web view warnings.
    • engine tests_pdf::bad_options_are_refused (1.2 row, new 1.3 rows) and options_not_applied_yet_and_document_features_warn.
    • tests_pdfpresets::saved_presets_apply_wherever_a_preset_is_named
    • tests_pdfx::choosing_a_pdfx_standard_… (1.4 → 1.3)
    • ui save_pdf: three dialog tests.
  • docs/mcp.md code fences are balanced.

🤖 Generated with Claude Code

bflatastic and others added 2 commits October 5, 2026 18:05
Embed Page Thumbnails gives every page a /Thumb image: the page drawn on
white, 106 px on its long side, without the layers the page leaves out
(the engine draws them; vectorcraft_pdf::page_areas says what each page
shows; PDF/X files get grey ones). Optimize for Fast Web View writes a
linearised file: the objects are put in linearised order and numbering,
encrypted when a password asks (the encryption dictionary goes with the
catalog, PDF layers' groups too), then laid out with the linearization
dictionary, both cross-reference tables and the page offset and shared
object hint tables (the hint stream encrypted like any other). Their
"not applied yet" warnings are gone. Reading the objects back uses the
lexer of encrypt.rs (syntax.rs adds what rewriting needs).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…preset

compatibility "1.3" writes a %PDF-1.3 file (its XMP metadata says 1.3
too) without transparency: a copy of the document is flattened first
with flattenerPreset (stored with PDF presets; empty is High Resolution)
and the flattener options over it, see-through image pixels counting as
transparency and rasterized areas clipped to their regions so no soft
mask is needed. Page groups are left out and the writer refuses a file
that would still have transparency. PDF/X-1a and PDF/X-3 share this
path (their version is now PDF 1.3; 1.4 is still accepted and written
as 1.3), and with it the preset, the header and metadata code and the
transparency check. Passwords at PDF 1.3 encrypt with 40-bit RC4
(revision 2). The Save PDF dialog lists PDF 1.3 and picks the flattener
preset under Advanced.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bflatastic
bflatastic merged commit cd8973a into main Oct 5, 2026
@bflatastic
bflatastic deleted the pr/m4-pdf-thumbs-linearize-13 branch October 5, 2026 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant