New High-Level HTML to PDF/UA API
Intro
With the release of version 6.2.0 of the pdfHTML add-on for iText Core, we’ve extended its advanced HTML to PDF capabilities with a brand‑new API to make the generation of PDF/UA (Universal Accessibility) documents much easier than it was previously.
With this new high-level API, it takes just a couple of extra lines to generate accessible documents that conform to the PDF/UA standards — including the brand‑new PDF/UA‑2 profile that targets PDF 2.0.
This functionality is packaged as a one-step solution where the converter reads the HTML and is able to derive headings, lists, tables and other semantic information automatically, ensuring a minimal maintenance overhead.
What’s new?
Feature | Why it matters |
---|---|
High level UA support switch via the new property on the ConverterProperties Object
| Allows switching on UA support with a single line; no custom role mapping or manual tagging required! |
PDF 2.0 readiness by combining with the existing Writerproperties setVersion property
| PDF/UA‑2 conformance requires PDF 2.0 under the hood; pdfHTML 6.2.0 lets you meet that requirement out of the box. |
How it works
// Input HTML and target file
String html = "report.html";
String pdf = "report-ua2.pdf";
// 1. Tell the converter which UA level to target
ConverterProperties cProps = new ConverterProperties();
cProps.setPdfUaConformance(PdfUaConformance.PDF_UA_2);
// 2. Use PDF 2.0 when you want UA‑2
WriterProperties wProps = new WriterProperties();
wProps.setPdfVersion(PdfVersion.PDF_2_0);
PdfWriter writer = new PdfWriter(pdf, wProps)
// 3. Convert
HtmlConverter.convertToPdf(new FileInputStream(html), writer, cProps);
// Input HTML and target file
String html = "report.html";
String pdf = "report-ua2.pdf";
// 1. Tell the converter which UA level to target
ConverterProperties cProps = new ConverterProperties();
cProps.SetPdfUaConformance(PdfUaConformance.PDF_UA_2);
// 2. Use PDF 2.0 when you want UA‑2
WriterProperties wProps = new WriterProperties();
wProps.SetPdfVersion(PdfVersion.PDF_2_0);
PdfWriter writer = new PdfWriter(pdf, wProps)
// 3. Convert
HtmlConverter.ConvertToPdf(new FileStream(html, FileMode.Open), writer, cProps);