Create PDF/UA and PDF/A Compliant Documents

HiQPdf HTML to PDF Converter can be configured to automatically generate PDF documents compliant with accessibility and archival standards by setting the PdfDocumentControlPdfStandard property. An object of PdfDocumentControl type is exposed by the HtmlToPdfDocument property

You can generate PDF documents compliant with PDF/UA-1, PDF/UA-2, PDF/A-2b, PDF/A-2a, PDF/A-3b, PDF/A-3u, PDF/A-3a, PDF/A-4, PDF/A-4f or combinations of these standards

PDF/UA standards define accessibility requirements, while PDF/A standards ensure long-term document archiving

The following PDF standards are supported

  • Set the PdfDocumentControlPdfStandard property to PdfStandardPdfUa1 to create a tagged PDF document conforming to the PDF/UA-1 (ISO 14289-1) Universal Accessibility standard for screen readers and assistive technologies

  • Set it to PdfStandardPdfUa2 to create a tagged PDF document conforming to the PDF/UA-2 (ISO 14289-2) Universal Accessibility standard, based on PDF 2.0

  • Set it to PdfStandardPdfA2b to create a PDF document conforming to the PDF/A-2b (ISO 19005-2, level B) standard for basic long-term archiving

  • Set it to PdfStandardPdfA2a to create a tagged PDF document conforming to the PDF/A-2a (ISO 19005-2, level A) standard for accessible long-term archiving

  • Set it to PdfStandardPdfA3b to create a PDF document conforming to the PDF/A-3b (ISO 19005-3, level B) standard for basic long-term archiving with support for embedded files of arbitrary type

  • Set it to PdfStandardPdfA3u to create a PDF document conforming to the PDF/A-3u (ISO 19005-3, level U) standard for long-term archiving with guaranteed Unicode character mappings and support for embedded files of arbitrary type

  • Set it to PdfStandardPdfA3a to create a tagged PDF document conforming to the PDF/A-3a (ISO 19005-3, level A) standard for accessible long-term archiving with support for embedded files of arbitrary type

  • Set it to PdfStandardPdfA4 to create a PDF document conforming to the PDF/A-4 (ISO 19005-4) standard, based on PDF 2.0, for long-term archiving

  • Set it to PdfStandardPdfA4f to create a PDF document conforming to the PDF/A-4f (ISO 19005-4, Files subset) standard, based on PDF 2.0, for long-term archiving with explicit support for embedded files of arbitrary type. Modern equivalent of PDF/A-3

  • Set it to PdfStandardPdfUa1PdfA2b to create a tagged PDF document conforming to both PDF/UA-1 and PDF/A-2b standards for accessibility and long-term archiving

  • Set it to PdfStandardPdfUa1PdfA2a to create a tagged PDF document conforming to both PDF/UA-1 and PDF/A-2a standards for accessibility and long-term archiving

  • Set it to PdfStandardPdfUa1PdfA3a to create a tagged PDF document conforming to both PDF/UA-1 and PDF/A-3a standards for accessibility and long-term archiving with support for embedded files of arbitrary type

  • Set it to PdfStandardPdfUa2PdfA2b to create a tagged PDF document conforming to both PDF/UA-2 and PDF/A-2b standards for accessibility and long-term archiving

  • Set it to PdfStandardPdfUa2PdfA2a to create a tagged PDF document conforming to both PDF/UA-2 and PDF/A-2a standards for accessibility and long-term archiving

  • Set it to PdfStandardPdfUa2PdfA4 to create a tagged PDF document conforming to both PDF/UA-2 and PDF/A-4 standards for accessibility and long-term archiving

  • Set it to PdfStandardPdfUa2PdfA4f to create a tagged PDF document conforming to both PDF/UA-2 and PDF/A-4f standards for accessibility and long-term archiving with support for embedded files of arbitrary type. Recommended modern combination for PDF 2.0

Code Sample - Auto Create PDF/UA and PDF/A

C#
using System.IO;
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using HiQPdf_Next_AspNetDemo.Models;

using HiQPdf.Next;

namespace HiQPdf_Next_AspNetDemo.Controllers
{
    public class CreatePdfUaAndPdfAController : Controller
    {
        IWebHostEnvironment m_hostingEnvironment;

        public CreatePdfUaAndPdfAController(IWebHostEnvironment hostingEnvironment)
        {
            m_hostingEnvironment = hostingEnvironment;
        }

        public IActionResult Index()
        {
            var model = SetViewModel();

            return View(model);
        }

        [HttpPost]
        public ActionResult ConvertToPdf(CreatePdfUaAndPdfAViewModel model)
        {
            if (!ModelState.IsValid)
            {
                var errorMessage = ModelStateHelper.GetModelErrors(ModelState);
                throw new ValidationException(errorMessage);
            }

            // Set the serial number received after purchase to use the library in licensed mode; leave it commented for demo mode
            // Licensing.SerialNumber = "your-serial-number";

            // Create an HTML to PDF converter object with default settings
            HtmlToPdf htmlToPdfConverter = new HtmlToPdf();

            // Sets the PDF standard for the generated document
            // Leave as None to generate a plain PDF without an accessibility structure tree or archival metadata
            htmlToPdfConverter.Document.PdfStandard = model.PdfStandard;

            // convert HTML to PDF
            byte[] pdfBuffer = null;

            if (model.UrlOrHtmlCode == "ConvertUrl")
            {
                // convert URL to a PDF memory buffer
                string url = model.Url;

                pdfBuffer = htmlToPdfConverter.ConvertUrlToMemory(url);
            }
            else
            {
                // convert HTML code
                string htmlCode = model.HtmlCode;
                string baseUrl = model.BaseUrl;

                // convert HTML code to a PDF memory buffer
                pdfBuffer = htmlToPdfConverter.ConvertHtmlToMemory(htmlCode, baseUrl);
            }

            FileResult fileResult = new FileContentResult(pdfBuffer, "application/pdf");
            fileResult.FileDownloadName = "PdfStandards.pdf";

            return fileResult;
        }

        private CreatePdfUaAndPdfAViewModel SetViewModel()
        {
            var model = new CreatePdfUaAndPdfAViewModel();

            var contentRootPath = Path.Combine(m_hostingEnvironment.ContentRootPath, "wwwroot");

            model.HtmlCode = System.IO.File.ReadAllText(Path.Combine(contentRootPath, "DemoFiles/Html/PDF_Standards.html"));

            return model;
        }
    }
}

See Also