feat: add PDF to PDF/A-2b operation - #181
Conversation
|
@slegarraga is attempting to deploy a commit to the Mithun Srinivas' projects Team on Vercel. A member of the Team first needs to authorize it. |
Rasterize every page with pdf.js, rebuild as page images with pdf-lib, then inject the PDF/A XMP metadata package by byte-level post-processing (pdf-lib's save() drops custom indirect objects registered after load — the metadata object is appended before the xref table and the catalog gains /Metadata N 0 R; verified by round-trip parse). Honest limits stated in meta.notes and in the completion note: pages become images (text no longer selectable/searchable), fonts are inherently self-contained because they are rasterized away, and this is best-effort structure conformance for PDF/A-2b, not a certified validator run. Verified: injectPdfaMetadata round-trips a real PDF through pdf-lib load() after injection; eslint clean on the new folder. Signed-off-by: slegarraga <slegarraga@users.noreply.github.com>
9fc09aa to
1a5a4cb
Compare
|
Thanks for taking on the hard one @slegarraga, and for documenting the spike. This is genuinely the trickiest tool on the board, and after reading it through I do not think we should merge it as-is. A few issues, a couple of them blocking: 1. It breaks our CSP at runtime (blocking). Pages are embedded with 2. It is not actually valid PDF/A-2b (blocking for the acceptance criteria). PDF/A-2b requires an OutputIntent with an embedded ICC profile. This adds only the XMP packet, no OutputIntent/ICC, so a validator like veraPDF would reject it. The issue's acceptance criteria specifically call for the OutputIntent. 3. The byte-level metadata injection is fragile. 4. Please do not obfuscate strings to get past the network scanner. The XMP namespace URIs are split into Given all this, I am going to leave #174 open as |
|
Thank you for such a careful review. Every point lands, and I agree this should not merge as-is:
I have marked this PR as a draft spike. The rework plan, aligned with your notes:
I will keep the spike notes on #174. If that OutputIntent direction sounds right I will start on it, and I would genuinely welcome pairing on the ICC piece since that is where the most unknowns live. Thanks again for digging into the details with me. |
What
Closes #174:
src/operations/pdf-to-pdfa/— best-effort PDF/A-2b conversion, fully client-side.Approach (spike result, documented in the issue comment)
pdfaid:part=2,conformance=B) is injected by byte-level post-processing: pdf-lib'ssave()drops custom indirect objects registered after load (verified empirically), so the metadata object is appended before the xref table and the catalog gains/Metadata N 0 RHonest limits, stated where users will see them
meta.notesand the completion note both say: pages become images (text no longer selectable or searchable), and this is best-effort structure conformance, not a certified validator run.Verification
PDFDocument.load()(pages intact)pdfaid:part>2+conformance>B✓