aeat.adapters.inbound.sanitizer._metadata module¶
DocInfo + XMP scrub for adapters.inbound.sanitizer.
Two surfaces, two scrubbers:
scrub_docinfo()deletes the legacy DocInfo dictionary (Title,Subject,Author,Keywords,Creator,Producer,CreationDate,ModDate, plus any custom keys). DocInfo is the original PDF metadata format; AEAT justificantes still write to it on every render, often with the CSV embedded in theTitleandSubjectstrings.scrub_xmp()deletes the XMP packet (Root.Metadata) wholesale by default. Per-key deletion leaves orphan namespace declarations (pikepdf/pikepdf#89); therewritestrategy is available for callers that must keep a minimal XMP packet, but the default is to drop it.
Both scrubbers also clear the PDF/A conformance claim — rewriting
Tj operands invalidates PDF/A-1B’s content/XMP alignment, so
leaving the claim intact would be dishonest.
- scrub_docinfo(pdf)[source]¶
Drops the entire DocInfo dictionary from
pdf.- Parameters:
pdf (
Pdf) – An openpikepdf.Pdfinstance whose DocInfo should be wiped. Modifiespdfin place.- Return type:
- Returns:
A
ScrubbedSurfacecarrying the count of DocInfo keys that were present before the wipe (zero when the document had no DocInfo dictionary).
- scrub_xmp(pdf, *, strategy='delete')[source]¶
Drops or rewrites the XMP metadata packet on
pdf.- Parameters:
pdf (
Pdf) – An openpikepdf.Pdfinstance whose XMP packet should be scrubbed. Modifiespdfin place.strategy (
Literal['delete','rewrite']) –"delete"(default) wipesRoot.Metadatawholesale;"rewrite"clears every PII-bearing entry while keeping the packet intact (useful when a downstream consumer still asserts the packet exists).
- Return type:
- Returns:
A 2-tuple of (counter, warnings). The counter is a
ScrubbedSurfacerecording how many top-level XMP entries were affected; the warning tuple containsSanitizationWarningentries, includingpdfa_claim_invalidatedwhen the original packet declared PDF/A conformance.