fix(pdf): Flate-compress the exported PDF streams

printpdf 0.9's `PdfSaveOptions::optimize` is a no-op — its `doc.compress()`
call is commented out — so every page's content stream (megabytes of vector
operators for a CAD sheet) was written uncompressed: a 16-sheet drawing set
exported as 280 MB. Serialise through `printpdf::to_lopdf_doc` and run
lopdf's `compress()` before writing; the same export is now 49 MB and
readers see ordinary FlateDecode streams.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Chris YehandClaude Opus 5 committed 2026-09-21 22:02:13 +08:00
1 parent 876513d009
commit 4826cd7989
3 files changed
+13 -1

No files matched your search

+2
View File
@@ -93,6 +93,8 @@ i18n-embed = { version = "0.16", features = ["desktop-requester"] }
rayon = "1"
open = "5"
printpdf = { version = "0.9.1", default-features = false, features = ["images"] }
# The lopdf printpdf builds on: used to Flate-compress the exported PDF streams.
lopdf = { version = "0.39.0", default-features = false, features = ["time"] }
ureq = { version = "3", default-features = false, features = ["rustls", "platform-verifier", "win-system-proxy"] }
[target.'cfg(target_arch = "wasm32")'.dependencies]