Create PDF/UA and PDF/A Compliant Documents

EVO HTML to PDF Converter can be configured to automatically generate PDF documents compliant with accessibility and archival standards by setting the PdfDocumentOptionsPdfStandard property. An object of PdfDocumentOptions type is exposed by the HtmlToPdfConverterPdfDocumentOptions 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 PdfDocumentOptionsPdfStandard 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;
using System.IO;
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using EvoPdf_Next_AspNetDemo.Models;
using EvoPdf_Next_AspNetDemo.Models.HTML_to_PDF;

// Use EVO PDF Namespace
using EvoPdf.Next;

namespace EvoPdf_Next_AspNetDemo.Controllers.HTML_to_PDF
{
    public class Create_PdfUa_and_PdfAController : Controller
    {
        private readonly IWebHostEnvironment m_hostingEnvironment;
        public Create_PdfUa_and_PdfAController(IWebHostEnvironment hostingEnvironment)
        {
            m_hostingEnvironment = hostingEnvironment;
        }

        public IActionResult Index()
        {
            var model = SetViewModel();
            return View(model);
        }

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

            // Set license key received after purchase to use the converter in licensed mode
            // Leave it not set to use the library in demo mode
            Licensing.LicenseKey = "3FJDU0ZDU0NTQkddQ1NAQl1CQV1KSkpKU0M=";

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

            // 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.PdfDocumentOptions.PdfStandard = model.PdfStandard;

            byte[] outPdfBuffer = null;

            if (model.HtmlPageSource == "Url")
            {
                string url = model.Url;

                outPdfBuffer = htmlToPdfConverter.ConvertUrl(url);
            }            
            else
            {
                string htmlWithForm = model.HtmlString;
                string baseUrl = model.BaseUrl;

                outPdfBuffer = htmlToPdfConverter.ConvertHtml(htmlWithForm, baseUrl);
            }

            // Send the PDF file to browser
            FileResult fileResult = new FileContentResult(outPdfBuffer, "application/pdf");
            fileResult.FileDownloadName = "PDF_Standards.pdf";

            return fileResult;
        }

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

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

            HttpRequest request = ControllerContext.HttpContext.Request;
            UriBuilder uriBuilder = new UriBuilder();
            uriBuilder.Scheme = request.Scheme;
            uriBuilder.Host = request.Host.Host;
            if (request.Host.Port != null)
                uriBuilder.Port = (int)request.Host.Port;
            uriBuilder.Path = request.PathBase.ToString() + request.Path.ToString();
            uriBuilder.Query = request.QueryString.ToString();

            string currentPageUrl = uriBuilder.Uri.AbsoluteUri;
            string rootUrl = currentPageUrl.Substring(0, currentPageUrl.Length - "PDF_Standards".Length);

            model.HtmlString = System.IO.File.ReadAllText(Path.Combine(contentRootPath, "DemoAppFiles/Input/HTML_Files/PDF_Standards.html"));
            model.BaseUrl = rootUrl + "DemoAppFiles/Input/HTML_Files/";

            return model;
        }
    }
}

See Also