Skip to content

feat: scrub PDF metadata after redaction - #11

Open
federicodeponte wants to merge 1 commit into
Siddharth-Khattar:mainfrom
federicodeponte:metadata-scrubbing
Open

feat: scrub PDF metadata after redaction#11
federicodeponte wants to merge 1 commit into
Siddharth-Khattar:mainfrom
federicodeponte:metadata-scrubbing

Conversation

@federicodeponte

Copy link
Copy Markdown

Summary

  • Adds a scrubMetadata() helper in frontend/src/engine/pdf.ts that clears all standard PDF info dictionary fields (Title, Author, Subject, Keywords, Creator, Producer, CreationDate, ModDate) using MuPDF's Document.setMetaData() API
  • Removes XMP metadata by deleting the Metadata stream from the PDF catalog via PDFDocument.getTrailer() low-level access
  • Calls scrubMetadata() in both applyRedactions and applyPseudonymisation right before saveToBuffer, ensuring all redacted output is metadata-clean

Closes #4

Implementation details

MuPDF's WASM TypeScript bindings expose:

  • Document.setMetaData(key, value) for clearing info dictionary entries
  • PDFDocument.getTrailer() and PDFObject.delete() for removing the XMP metadata stream from the catalog

Both operations are wrapped in try/catch for graceful degradation if specific keys or low-level operations are unsupported in a given MuPDF build.

Test plan

  • Upload a PDF with metadata (Title, Author, etc.) and run redaction; verify output has no metadata via pdfinfo or a PDF metadata viewer
  • Upload a PDF with XMP metadata; verify the XMP stream is removed after redaction
  • Run pseudonymisation on a PDF with metadata; verify output is metadata-clean
  • TypeScript type checking passes: tsc --noEmit (verified locally)

Add scrubMetadata() helper that clears all standard info dictionary
fields (Title, Author, Subject, Keywords, Creator, Producer,
CreationDate, ModDate) and removes XMP metadata from the PDF catalog.

Called in both applyRedactions and applyPseudonymisation right before
saveToBuffer, so redacted documents no longer leak identifying metadata.

Closes Siddharth-Khattar#4

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

Bug: PDF metadata not scrubbed after redaction

1 participant