Skip to content
Apply PDF/A-3 Standard

Apply PDF/A-3 Standard

Applying PDF/A-3 rewrites a document to ISO 19005-3 as it is written out, raising the PDF version to at least 1.7. Every step is the same as PDF/A-2 apart from what is allowed to be attached: part 3 permits any embedded file type, part 2 only permits embedded PDF/A. Pick part 3 when the document carries a non-PDF payload, which in practice means invoice formats such as ZUGFeRD and Factur-X.

Three profiles, one per conformance level: pdfa.NewProfile3B, pdfa.NewProfile3U and pdfa.NewProfile3A. Applying a profile does not add what its level requires, so 3B is the right choice for converting an existing file. NewProfile3U will not synthesize ToUnicode CMaps, and NewProfile3A sets MarkInfo Marked to true and inserts an empty StructTreeRoot without tagging content.

Doing it

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

pdfWriter.ApplyStandard(pdfa.NewProfile3B(nil))

return pdfWriter.WriteToFile(outputPath)

ApplyStandard registers the profile; the rewrite happens during Write. Passing nil gives DefaultProfile3Options, with time.Now as the clock and a tab as the XMP indent. CMYKDefaultColorSpace selects CMYK instead of RGB as the target when the document mixes device color spaces.

Attaching the payload is a separate step and is not something ApplyStandard does. Add the file specification before writing, and give it F, UF and AFRelationship entries, since validation requires all three. See attachments.

Limitations

The applier does not create or repair file specifications. A document whose attachments lack UF or AFRelationship will convert without complaint and then fail validation on rules 6.8-2 and 6.8-3. Fix the attachment when you add it.

Fonts 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, and Write fails with no matching font found in the system if none is installed. Substitutes are not metrically matched, so text can reflow.

Interactive behavior does not survive. Every annotation gets its Print flag set and its Invisible, Hidden, NoView and ToggleNoView flags cleared. Widget annotations and field dictionaries lose their A and AA entries, and the AcroForm dictionary loses XFA.

Applying the profile does not guarantee the result validates. Check the output with validation, and with veraPDF before claiming conformance.

Run the example

pdfa3_apply_standard.go reads a file, converts it with NewProfile3B and writes the result. The only PDF/A-specific line is the ApplyStandard call in main.

git clone https://github.com/unidoc/unipdf-examples.git
cd unipdf-examples/pdfa
go run pdfa3_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: 132.17 ms
Last updated on