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, WTPDF 1.0 or combinations of these standards

The PDF/UA standards make the document accessible to screen readers and assistive technologies, the PDF/A standards make it suitable for long-term archiving and WTPDF (Well-Tagged PDF) is the PDF Association specification for accessible and reusable PDF 2.0 documents, based on PDF/UA-2. Accessible documents are required by the European Accessibility Act for the documents that businesses deliver to consumers, such as invoices, statements and contracts

The converter builds the structure of the accessible document from the HTML: the headings, the paragraphs, the lists, the tables with their header cells, the links and the alternate text of the images carry over to the PDF, together with the document language and title

The following PDF standards are supported

The documents produced for these standards can be password protected and digitally signed like any other generated document. The PDF 2.0 documents are encrypted with AES 256 unless another algorithm is selected

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 the license key received after purchase to use the library in licensed mode; leave it commented for demo mode
            // Licensing.LicenseKey = "your-license-key";

            // 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;

            // PDF/A-4f is the PDF/A-4 variant for documents with embedded files and requires at least one
            if (model.PdfStandard == PdfStandard.PdfA4f || model.PdfStandard == PdfStandard.PdfUa2PdfA4f
                || model.PdfStandard == PdfStandard.Wtpdf1PdfA4f)
            {
                var textAttachment = PdfFileAttachment.FromFile(Path.Combine(m_hostingEnvironment.ContentRootPath,
                    "wwwroot", "DemoAppFiles", "Input", "Text_Files", "Alphabet.txt"));
                textAttachment.MimeType = "text/plain";
                textAttachment.Description = "Sample text file";
                htmlToPdfConverter.PdfDocumentOptions.AddFileAttachment(textAttachment);
            }

            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 - "Create_PdfUa_and_PdfA".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