Skip to content
Apply PDF/A-1 Standard

Apply PDF/A-1 Standard

Applying PDF/A-1 rewrites a document to ISO 19005-1 as it is written out. Of the four parts this is the one that changes content rather than only metadata, because PDF/A-1 is based on PDF 1.4 and forbids transparency.

Pick NewProfile1B unless the content is already tagged. NewProfile1A additionally sets MarkInfo Marked to true and inserts a StructTreeRoot when the catalog has none, but it cannot tag page content, so running it on an untagged file produces a document that looks tagged to UniPDF’s own validator and is not.

Doing it

pdfWriter, err := reader.ToWriter(nil)
if err != nil {
    return err
}

pdfWriter.ApplyStandard(pdfa.NewProfile1B(nil))

return pdfWriter.WriteToFile(outputPath)

ApplyStandard only registers the profile. The document is rewritten inside Write, so that is where conversion errors surface. Passing nil for the options uses DefaultProfile1Options: time.Now as the clock, and a tab as the XMP indent. The one option usually worth setting is CMYKDefaultColorSpace, which makes CMYK rather than RGB the target when the document mixes device color spaces.

Limitations

Transparency is flattened, not rejected. Images with a soft mask are converted to RGBA, the alpha is folded into the image data and the SMask stream is dropped from the document. Transparency groups are removed from pages, from form XObjects and from the XObject resources dictionary. The output is a valid PDF 1.4 file, and how close it looks to the input depends on what the transparency was doing. Overlapping semi-transparent artwork is where this goes wrong.

Fonts that are referenced but not embedded are replaced with a font found on the machine running the conversion, falling back to Times New Roman, Arial and DejaVu Sans. If none is installed, Write fails with no matching font found in the system. Substitutes are not metrically matched, so text can reflow.

Every annotation gets its Print flag set and its Invisible, Hidden, NoView and ToggleNoView flags cleared, whether or not it was in violation. Annotations that were hidden on purpose become visible.

PDF/A-1 forbids embedded files outright, and the applier does not remove them. A document with attachments needs PDF/A-2 or PDF/A-3, or the attachments stripped first.

Applying the profile does not guarantee the result validates. Run validation on the output, and an independent checker such as veraPDF before making a conformance claim.

Run the example

pdf_apply_standard.go reads a file, converts it with NewProfile1B and writes the result, printing the elapsed time. Everything specific to PDF/A is the single ApplyStandard call in main.

git clone https://github.com/unidoc/unipdf-examples.git
cd unipdf-examples/pdfa
go run pdf_apply_standard.go <input.pdf> <output.pdf>

If this is your first time using UniPDF, follow the getting started guide to create an API key and set up your development environment.

View the full source
Processing time: 23.17 ms

Sample output

Document properties of the converted file showing the PDF/A-1 conformance claim

Last updated on