PDF/A and archiving: what your PDF actually contains

A PDF is a container, and the extension tells you nothing about what is inside it. Two files that look identical on screen can differ completely: one holds real text you can search and select, the other holds a photograph of text and nothing else. That difference decides whether the document is findable today. A separate set of choices, about fonts, colour and external references, decides whether it still renders in ten years. The format standardises the envelope, and almost nothing about durability comes free with it.

A PDF is a page description, not a document format

ISO 32000-1:2008, published July 2008, was the first PDF specification issued by ISO, formalising Adobe's PDF 1.7. Its scope is a viewing format: it lets people "exchange and view electronic documents independent of the environment in which they were created or the environment in which they are viewed or printed". PDF 2.0 is ISO 32000-2:2020, second edition, December 2020.

The OCRmyPDF documentation states the consequence plainly: "PDFs are page description files that attempt to preserve a layout exactly." And a warning most people miss: "A PDF page may contain multiple images, even if it appears to have only one image." Scanner software routinely splits a page into a monochrome text layer and a colour background layer for compression.

Three commands from poppler-utils settle what you actually have. pdftotext "converts Portable Document Format (PDF) files to plain text"; empty output means no text layer exists. pdffonts "lists the fonts used in a Portable Document Format (PDF) file along with various information for each font"; a file with no font rows has no text. pdfimages -list will "list the images along with various information for each image"; one page-sized image per page is a scan.

What three visually identical PDFs contain Three PDF pages that render the same on screen. The first holds a real text layer, the second holds only a scanned image, the third holds a scanned image plus an invisible OCR text layer. Below each page, the output of pdftotext, pdffonts and pdfimages list differs completely. Three files that render identically Text layer PDF Scan in a PDF Scan plus OCR glyphs and fonts one image pixels only image plus hidden text pdftotext the real text nothing the OCR guess pdffonts embedded fonts no rows at all one unseen font pdfimages -list no page image one per page one per page The OCR font is drawn in text rendering mode 3, so it is never painted. The pixels you read are still the scan.
Three PDFs that look identical on screen, and what pdftotext, pdffonts and pdfimages report for each.

What OCR adds, and how it fails

OCR does not convert a scan into a text document. It adds a second, invisible layer on top of the unchanged pixels, drawn in text rendering mode 3, which veraPDF's formalisation of the PDF/A rules describes as the mode where "glyphs are not stroked, filled or used as a clipping boundary". OCRmyPDF is honest about the mechanism: "It uses OCR to guess the text contained in images."

Input quality drives the guess. Tesseract's own guidance says it "works best on images which have a DPI of at least 300 dpi", that "the quality of Tesseract's line segmentation reduces significantly if a page is too skewed", and that some noise "cannot be removed by Tesseract in the binarisation step, which can cause accuracy rates to drop".

The realistic failure modes are documented, not hypothetical. OCRmyPDF lists them: "It is incapable of recognizing handwriting." "It may detect gibberish and report it as OCR output." "Tesseract may struggle to analyze the natural reading order of documents." And the structural limit that matters for archiving: "Tesseract does not divide text into paragraphs or headings. It only provides the text and its bounding box. As such, the generated PDF does not contain any information about the document's structure."

The US National Archives accepts imperfect OCR and rejects destructive OCR. It takes "PDF records with uncorrected OCR'd text", but "will not accept PDF records resulting from OCR processes that alter the visible content, degrade the quality of the original bit-mapped image, or replace the original bit-mapped image with OCR'd text."

The compression that rewrites your numbers

On 24 July 2013 David Kriesel found that Xerox WorkCentre devices "randomly alter written numbers in pages that are scanned". His description of the failure is the reason scanned PDFs deserve suspicion: "This is not an OCR problem", it is "patches of the pixel data are randomly replaced in a very subtle and dangerous way", and "The scanned images look correct at first glance, even though numbers may actually be incorrect."

The cause was JBIG2 symbol matching used in its lossy mode. The encoder groups visually similar glyph patches and stores one representative for the group, so a 6 that the matcher considers close enough to an 8 is redrawn as an 8. Kriesel puts the distinction in one line: "PM&S works lossy, SPM lossless."

Two archives turned that into policy. Germany's BSI Technical Guideline TR-03138 (RESISCAN), version 1.4.1 of 23 April 2020, rules that image compression methods using symbol coding "DÜRFEN NICHT eingesetzt werden", must not be used. NARA is equally direct: it "will not accept digitized records in PDF that have been saved with lossy compression to reduce file size (e.g., JPEG, JBIG2)", and it names the scanner presets that produce it, listing "Searchable Image - Compact" among prohibited outputs and "Searchable Image - Exact" among acceptable ones. Those two menu entries differ by one word and by whether your figures survive.

What PDF/A actually standardises

PartStandardPublishedBase specificationConformance levels
PDF/A-1ISO 19005-1:2005October 2005PDF 1.4 (Adobe)a, b
PDF/A-2ISO 19005-2:2011July 2011ISO 32000-1 (PDF 1.7)a, b, u
PDF/A-3ISO 19005-3:2012October 2012ISO 32000-1, plus embedded filesa, b, u
PDF/A-4ISO 19005-4:2020November 2020ISO 32000-2 (PDF 2.0)4, 4e, 4f

PDF/A is defined as a set of prohibitions, and veraPDF publishes each one as a formalised "shall" statement. Five carry the weight.

Fonts must travel with the file: "The font programs for all fonts used within a conforming file shall be embedded within that file, as defined in PDF Reference 5.8, except when the fonts are used exclusively with text rendering mode 3." Encryption is banned outright: "The keyword Encrypt shall not be used in the trailer dictionary." External content is banned: "A stream object dictionary shall not contain the F, FFilter, or FDecodeParms keys." Active content is banned, in PDF/A-1 by name: "The Launch, Sound, Movie, ResetForm, ImportData and JavaScript actions shall not be permitted." And colour must be unambiguous, because "all colours shall be specified in a device-independent manner, either directly by the use of a device-independent colour space, or indirectly by the use of an OutputIntent."

OCRmyPDF condenses the whole family into one rule: "All fonts and resources needed to interpret the PDF must be contained within it."

Conformance levels are not quality grades

Level b promises only that the page renders the same way later. Level u adds machine-readable text: rule 6.2.11.7.2-1, which applies to levels A and U, requires that "The Font dictionary of all fonts shall define the map of all used character codes to Unicode values, either via a ToUnicode entry, or other mechanisms". Without it, text can be selected and copied out as nonsense. pdffonts reports this per font in its uni column, which reads "yes" if there is an explicit "ToUnicode" map in the PDF file.

Level a additionally requires logical structure tagging, which a plain OCR pipeline cannot deliver, because Tesseract "only provides the text and its bounding box".

PDF/A-4 abandoned that ladder. veraPDF's supported profiles are "PDF/A-1a, PDF/A-1b, PDF/A-2a, PDF/A-2b, PDF/A-2u, PDF/A-3a, PDF/A-3b, PDF/A-3u, PDF/A-4, PDF/A-4e, PDF/A-4f": no 4a, 4b or 4u exists. PDF/A-4 also reversed a 2005 decision. Its action rule reads "The Launch, Sound, Movie, ResetForm, ImportData, Hide, Rendition and Trans actions shall not be permitted", and JavaScript is no longer on that list. The newest archival PDF standard permits scripting the 2005 one forbade.

The four PDF/A parts and their conformance levels The four parts of the PDF/A standard against the base specification each one profiles and the conformance levels each offers. PDF/A-1, ISO 19005-1:2005, is built on PDF 1.4 and offers levels a and b. PDF/A-2, ISO 19005-2:2011, moves to ISO 32000-1:2008 and adds level u. PDF/A-3, ISO 19005-3:2012, keeps the same base and the same three levels, and relaxes the rules on embedded files. PDF/A-4, ISO 19005-4:2020, is built on ISO 32000-2:2020 and abandons the a, b and u ladder entirely: the conformance names are PDF/A-4, PDF/A-4e and PDF/A-4f, and no 4a, 4b or 4u exists. part standard base specification conformance levels PDF/A-1 ISO 19005-1:2005 PDF 1.4 a b PDF/A-2 ISO 19005-2:2011 ISO 32000-1:2008 a b u PDF/A-3 ISO 19005-3:2012 ISO 32000-1 a b u PDF/A-4 ISO 19005-4:2020 ISO 32000-2:2020 PDF/A-4 4e 4f Levels are not quality grades. Level b promises only that the page renders the same later; u adds a Unicode map so text extracts correctly; a adds logical structure tagging, which a plain OCR pipeline cannot produce because it returns only text and bounding boxes. PDF/A-4 dropped the ladder: there is no 4a, 4b or 4u. It also permits JavaScript, which the 2005 standard forbade. PDF/A forbids the Encrypt key, so a password-protected signed PDF cannot also be PDF/A.
The four PDF/A parts against their base specifications and conformance levels, showing that PDF/A-4 replaced the a, b and u ladder.

Why a file that renders today can fail later

Three mechanisms, all detectable before you archive.

Fonts that are referenced rather than embedded get substituted by whatever the future viewer has, and substitution changes glyph widths, so line breaks and table alignment move. pdffonts prints an emb column, "yes" if the font is embedded in the PDF file. Any no is a deferred rendering bug.

External resources fetched at render time simply stop resolving. That is what the ban on the F, FFilter and FDecodeParms stream keys exists to prevent.

Metadata that lies is the least obvious. Ghostscript's default PDFACompatibilityPolicy value is 0, which will "Include the feature or operation in the output file, the file will not be PDF/A compliant. Because the document Catalog is emitted before this is encountered, the file will still contain PDF/A metadata but will not be compliant." A PDF that announces PDF/A conformance in its XMP has not been checked by anything. Set the policy to 1 to drop offending features, or 2 to abort.

The check itself is free. veraPDF is "a purpose-built, open source, file-format validator covering all PDF/A and PDF/UA parts and conformance levels". For structural sanity below the standards layer, qpdf --check parses the file and reports; "An exit status of 0 indicates syntactic correctness of the PDF file."

A signature ages differently from the document

Under eIDAS, validation of a qualified electronic signature requires confirming that "the qualified certificate was issued by a qualified trust service provider and was valid at the time of signing". The operative phrase is at the time of signing, not now. Once the signing certificate expires, a verifier holding only the file cannot establish when the signature was made, or whether the certificate had already been revoked when it was made.

Timestamps close that gap. RFC 3161 defines a service that "supports assertions of proof that a datum existed before a particular time", which lets a verifier "verify that a digital signature was applied to a message before the corresponding certificate was revoked thus allowing a revoked public key certificate to be used for verifying signatures created prior to the time of revocation". An archival signed PDF therefore needs the full certificate chain, the revocation data that was current at signing, and a trusted timestamp, all embedded in the file rather than fetched later.

That evidence is itself perishable, because signing algorithms weaken. RFC 3161 says so: "any token signed by the TSA SHOULD be time-stamped again" at a later date "to renew the trust that exists in the TSA's signature". EU law names the resulting obligation. eIDAS Article 34 requires a qualified preservation service to use "procedures and technologies capable of extending the trustworthiness of the qualified electronic signature beyond the technological validity period". Long-term signature validity is a subscription, not a property of the file.

One collision to plan around: PDF/A forbids the Encrypt key, so a password-protected signed PDF cannot also be PDF/A.

Why a signature needs a timestamp to outlive its certificate A timeline running from the moment of signing, through the expiry of the signing certificate, to a verification attempt years later. On the upper track the file carries the signature alone: after the certificate expires a verifier holding only the file cannot establish when the signature was made or whether the certificate had already been revoked at that moment, so validation fails. On the lower track the file also carries a trusted timestamp, the full certificate chain and the revocation data that was current at signing, which proves the signature predates the expiry and lets validation succeed. Because signing algorithms weaken over time, the timestamp itself has to be renewed before it ages out. signed certificate expires verified years later signature only validates cannot establish when it was signed eIDAS asks whether the certificate was valid at the time of signing, and the file alone no longer proves what that time was. signature plus timestamp validates, because the timestamp proves the signature predates the expiry embedded at signing: certificate chain, revocation data current at that moment, trusted timestamp The evidence is perishable: any token signed by the timestamp authority should itself be time-stamped again later, to renew the trust in that signature. Long term signature validity is a subscription, not a property of the file. EU law puts the renewal duty on a qualified preservation service.
How signature validity depends on a timestamp once the signing certificate expires.

Keep the original next to the derivative

PDF/A-1 forbade attachments entirely. veraPDF's note on that rule records the loosening: "This requirement was relaxed in PDF/A-2 to embed other PDF documents conforming to either PDF/A-1 or PDF/A-2, and in PDF/A-3 to allow any embedded files." ISO 19005-3:2012 is titled, in part, "Use of ISO 32000-1 with support for embedded files".

Archives are not persuaded. NARA's instruction is "Select any version of PDF/A that meets project requirements. However, do not use the attachments feature in PDF/A-3 or PDF/A-4." An embedded spreadsheet is opaque to the preservation system that stores the PDF, and it inherits the PDF's fate.

The workable pattern is sibling files. Keep the scan master, uncompressed or losslessly compressed, keep the authored source document, and treat the searchable PDF/A as a derivative you can regenerate when the OCR engine improves. NARA's preferred format list ranks PDF/A-1 and PDF/A-2 for born-digital text and accepts TIFF 6 uncompressed or Deflate for digitised paper.

TaskFree toolCommand
Is there a text layer?poppler-utilspdftotext file.pdf -
Are fonts embedded, and Unicode-mapped?poppler-utilspdffonts file.pdf
Is the page one big scan?poppler-utilspdfimages -list file.pdf
Structural check and encryption stateqpdfqpdf --check file.pdf
PDF/A and PDF/UA validationveraPDFverapdf -f 2b file.pdf
Add an OCR text layerOCRmyPDFocrmypdf --output-type pdfa in.pdf out.pdf
Convert to PDF/AGhostscriptgs -dPDFA=1 -dBATCH -dNOPAUSE -sColorConversionStrategy=RGB -sDEVICE=pdfwrite -sOutputFile=out-a.pdf PDFA_def.ps input.ps

The Ghostscript route needs a PDF/A definition file whose /ICCProfile entry points at a real profile for the output intent, and that path "must be a fully qualified device and path specification appropriate for your Operating System". Nothing in the pipeline confirms the result. Run veraPDF over the output and believe the validator, not the writer.

Sources