PDF/A and PDF/UA
Convert documents to PDF/A for archiving or PDF/X for print, and tag them for PDF/UA accessibility, with NexPDF for Node.js.
License module
PDF/A, PDF/X and PDF/UA need the standards module (Enterprise tier).
PDF/A for archiving
doc.raw.convertPdfa() converts the document to PDF/A (ISO 19005): it writes the XMP metadata with
the PDF/A identification, adds an sRGB output intent with an embedded ICC profile and a file
identifier, and embeds metric-compatible Liberation fonts in place of non-embedded standard fonts.
The Node.js engine has the Liberation fonts compiled in.
import { PdfDocument } from '@nexdevit/nexpdf-node';
const doc = await PdfDocument.open('invoice.pdf');
doc.raw.convertPdfa();
await doc.save('invoice-pdfa.pdf');convertPdfa() writes PDF/A-2b. To convert to another level (1a to 4f) and check the result, use
doc.raw.convertPdfaLevel(level) and doc.raw.validatePdfaJson(level); see
PDF/A and PDF/UA validation.
PDF/X for print
doc.raw.convertPdfx();
await doc.save('print-ready.pdf');PDF/UA accessibility tagging
doc.raw.autoTag(lang, force) builds a logical structure tree from the page content of an untagged
document: text becomes headings (H1, H2) and paragraphs in reading order, images become
Figure elements with placeholder alternative text, annotations become Link, Form or Annot
elements, and vector graphics become artifacts. It also sets the language, the title,
/MarkInfo, the tab order and the PDF/UA identification. It returns a JSON report.
const report = JSON.parse(doc.raw.autoTag('en-US', 0)); // force = 1 re-tags an already tagged file
console.log(report.headings, report.paragraphs, report.figures, report.warnings);
await doc.save('accessible.pdf');The report counts pages, headings, paragraphs, figures, annotations and artifacts, says
whether the file was already_tagged, and lists warnings that need a person, such as figures that
need real alternative text.
lang is a BCP 47 tag such as pt-PT or en-US (null uses en-US). Check the result with
doc.raw.validatePdfuaJson(), or convert in one step to PDF/UA-1 or PDF/UA-2 with
doc.raw.convertPdfuaJson(part, lang); see PDF/A and PDF/UA validation.