Skip to main content
Skip table of contents

Improved HTML to PDF/A

With the latest advancements in pdfHTML 5.0.3, you can now generate PDF/A files directly from HTML even more easily than before! With just a few lines of code, the PDF/A conformance level and document output intent can be set directly in the HtmlConverter (Java/.NET) properties, creating fully compliant PDF/A files that adhere to archival standards.

What changed?

In earlier iterations of iText, while it was certainly feasible to generate PDF/A files through pdfHTML, the process was more complex than required, as developers were tasked with manually crafting a PdfADocument (Java/.NET) instance to add into the pdfHTML conversion process.

In our latest release, however, we've streamlined this procedure significantly: Now, developers can effortlessly create PDF/A documents by merely adjusting a few parameters to define the PDF/A conformance level and output intent in the ConverterProperties (Java/.NET) object. The underlying object instantiation processes are now handled seamlessly in the background, sparing developers the burden of manually setting up these objects.

Code Examples:

package com.itextpdf.samples.sandbox.pdfhtml;

import com.itextpdf.html2pdf.ConverterProperties;
import com.itextpdf.html2pdf.HtmlConverter;
import com.itextpdf.html2pdf.resolver.font.DefaultFontProvider;
import com.itextpdf.kernel.pdf.PdfAConformanceLevel;
import com.itextpdf.kernel.pdf.PdfOutputIntent;


public class HtmlToPdfA3Convert {
    public static final String SRC = "./src/main/resources/pdfhtml/HtmlToPdfA3Convert/";
    public static final String DEST = "./target/sandbox/pdfhtml/HtmlToPdfA3Convert.pdf";

    public static void main(String[] args) throws IOException {
        File file = new File(DEST);

        new HtmlToPdfA3Convert().manipulatePdf(DEST);

    public void manipulatePdf(String pdfDest) throws IOException {
        String htmlSource = SRC + "MixedContent.html";

        InputStream inputStream = new FileInputStream(SRC + "sRGB Color Space Profile.icm");

        ConverterProperties converterProperties = new ConverterProperties();
                new PdfOutputIntent("Custom", "", "", "sRGB IEC61966-2.1",

        converterProperties.setFontProvider(new DefaultFontProvider(false, true, false));

        HtmlConverter.convertToPdf(new FileInputStream(htmlSource), new FileOutputStream(pdfDest), converterProperties);
using System;
using System.IO;
using iText.Html2pdf;
using iText.Html2pdf.Resolver.Font;
using iText.Kernel.Pdf;
using static iText.Kernel.Pdf.PdfAConformanceLevel;

namespace iText.Samples.Sandbox.Pdfhtml 
    public class HtmlToPdfA3Convert 
        public static readonly string SRC = "../../../resources/pdfhtml/HtmlToPdfA3Convert/";
        public static readonly string DEST = "results/sandbox/pdfhtml/HtmlToPdfA3Convert.pdf";

        public static void Main(String[] args) 
            var file = new FileInfo(DEST);
            new HtmlToPdfA3Convert().ManipulatePdf(DEST);

        public void ManipulatePdf(String pdfDest) 
            var htmlSource = SRC + "MixedContent.html";
            var inputStream = new FileStream(SRC + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read);
            var converterProperties = new ConverterProperties();
            converterProperties.SetDocumentOutputIntent(new PdfOutputIntent("Custom", "", "",
            "sRGB IEC61966-2.1", inputStream));
            converterProperties.SetFontProvider(new DefaultFontProvider(false, true, false));
            HtmlConverter.ConvertToPdf(new FileStream(htmlSource, FileMode.Open, FileAccess.Read), new FileStream(pdfDest, FileMode.Create), converterProperties);

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.