Skip to Content
NexPDF

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 Android.

English

License module

PDF/A, PDF/X and PDF/UA need the standards module (Enterprise tier).

PDF/A for archiving

NexPdfJni.convertPdfA(handle) 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.

import com.nexdevit.nexpdf.NexPdfDocument
import com.nexdevit.nexpdf.NexPdfJni

NexPdfDocument.openBytes(invoiceBytes).use { doc ->
    check(NexPdfJni.convertPdfA(doc.handle())) { NexPdfJni.lastError() }
    val pdfa = doc.saveBytes()
}

convertPdfA writes PDF/A-2b. To convert to another level (1a to 4f) and check the result, use convertPdfaLevel(level) and validatePdfaJson(level); see PDF/A and PDF/UA validation.

PDF/X for print

check(NexPdfJni.convertPdfX(doc.handle())) { NexPdfJni.lastError() }
val printReady = doc.saveBytes()

PDF/UA accessibility tagging

NexPdfJni.autoTag(handle, 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.

val report = JSONObject(NexPdfJni.autoTag(doc.handle(), "en-US", false))   // true re-tags a tagged file
Log.i("NexPDF", "${report.getInt("headings")} ${report.getInt("paragraphs")} ${report.getInt("figures")} ${report.getJSONArray("warnings")}")
val accessible = doc.saveBytes()

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 validatePdfuaJson(). Conversion to PDF/UA-1 or PDF/UA-2 in one call, with a report, is the engine's convert_pdfua_json, reached through NexPdfJni.invoke; see PDF/A and PDF/UA validation.

On this page