SetPDFAMode

Document properties, Compliance

Description

Activates a PDF/A compliance mode for the selected document. A single call performs all the document-level setup required by the chosen PDF/A part and conformance level: the PDF version is bumped to the required minimum, the /MarkInfo entry is written when the tagged-PDF conformance level (A) is selected, an output intent (DeviceRGB sRGB ICC profile) is added to the Catalog, and the pdfaid:part/pdfaid:conformance XMP namespace entries are written. The library also activates a generation-side compliance guard that rejects subsequent calls which would emit content forbidden by the chosen part (see Remarks).

Call this once on a freshly created document and before adding any content. To validate an existing PDF/A file produced by this or any other library, use CheckFileCompliance with ComplianceTest = 1.

Syntax

Delphi

function TPDFlib.SetPDFAMode(NewMode: Integer): Integer;

ActiveX

Function PDFlib::SetPDFAMode(NewMode As Long) As Long

DLL

int DLSetPDFAMode(int InstanceID, int NewMode);

Parameters

NewModeThe PDF/A conformance mode to activate. Each mode is identified by a PDF/A part (1, 2, or 3 — ISO 19005-1/-2/-3) and a conformance level (B for basic visual reproduction, A for tagged-PDF accessibility).

0 — Disable PDF/A mode (default).
1 — PDF/A-1a (ISO 19005-1 Level A). PDF 1.4. Tagged PDF required.
2 — PDF/A-1b (ISO 19005-1 Level B). PDF 1.4. Visual reproduction only.
3 — PDF/A-2b (ISO 19005-2 Level B). PDF 1.7. Visual reproduction; transparency and layers permitted.
4 — PDF/A-2a (ISO 19005-2 Level A). PDF 1.7. Tagged PDF required.
5 — PDF/A-3b (ISO 19005-3 Level B). PDF 1.7. Like PDF/A-2b but allows arbitrary embedded files.
6 — PDF/A-3a (ISO 19005-3 Level A). PDF 1.7. Like PDF/A-2a but allows arbitrary embedded files.

Return values

0Failed — no document is open, or NewMode is outside the range 0–6.
1PDF/A mode activated successfully.

Remarks

The chosen mode controls a generation-side compliance guard. Once activated, the library refuses or rewrites subsequent calls that would emit content forbidden by the part, in line with ISO 19005:

CMYK / Separation / Shader colorsBlocked in every PDF/A mode (1–6) — the document is set up with an sRGB output intent and only colors compatible with the output intent's device class may be used.
EncryptionBlocked in every PDF/A mode. Set the mode before calling any encryption-related API.
Transparency / blend modes / page transparency groupsBlocked in modes 1 and 2 (PDF/A-1 forbids transparency). Allowed in modes 3–6 (PDF/A-2/3 permit transparency).
JavaScript actionsBlocked in every PDF/A mode — ISO 19005-1 §6.6.1 prohibits JavaScript and the prohibition is carried forward in PDF/A-2/3.
Embedded files / file attachmentsBlocked in modes 1–4 (PDF/A-1 forbids them; PDF/A-2 only allows PDF/A-conformant embedded PDFs, which the library does not enforce). Allowed in modes 5 and 6 — PDF/A-3 explicitly permits embedded files of any MIME type via the AFRelationship association.

The required tagged-PDF content (heading structure, alt text on figures, table scope attributes, RoleMap entries for custom types) is the caller's responsibility for the a levels (modes 1, 4, 6). Use BeginTag, BeginArtifact, AddRoleMap, and the structure-element setters to build the structure tree. Call GetPDFUADiagnostics before saving to surface the most common tagged-PDF issues.

PDF/A and PDF/UA can be activated on the same document. Activate SetPDFAMode first (parts 1a/2a/3a already imply tagged PDF) and then call SetPDFUAMode to add the PDF/UA-specific catalog setup (DisplayDocTitle, pdfuaid:part, auto /Tabs /S).

Example

// PDF/A-1b — minimum-effort archival document
PDF.NewDocument;
PDF.SetPDFAMode(2);                              // PDF/A-1b
PDF.SetDocumentInfo('Title', 'Quarterly Report Q1 2026');
PDF.AddStandardFont('Helvetica');
PDF.AddPage;
PDF.SetFontSize(12);
PDF.PrintText(50, 750, 'Quarterly Report — Q1 2026');
PDF.SaveToFile('Q1-Report-PDFA1b.pdf');

// PDF/A-3a — tagged report with an embedded source spreadsheet
PDF.NewDocument;
PDF.SetPDFAMode(6);                              // PDF/A-3a
PDF.SetPDFUAMode('en-US');                       // Optional: also satisfy PDF/UA-1
PDF.SetDocumentInfo('Title', 'Sales Analysis 2026');
PDF.AddStandardFont('Helvetica');
PDF.AddPage;
PDF.BeginTag('H1', '', '');
PDF.PrintText(50, 750, 'Sales Analysis');
PDF.EndTag;
PDF.BeginTag('P', '', '');
PDF.PrintText(50, 720, 'See attached spreadsheet for source data.');
PDF.EndTag;
PDF.EmbedFile('Source data', 'data.xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
PDF.SaveToFile('Sales-PDFA3a.pdf');

See also

CheckFileCompliance, SetPDFUAMode, SetMarkInfo, EmbedFile, BeginTag, GetPDFUADiagnostics, SetInformation