Auto Create Accessible Tagged PDF

Winnovative HTML to PDF Converter can be configured to automatically create a tagged PDF by simply turning on the PdfDocumentOptionsGenerateTaggedPdf option. An object of PdfDocumentOptions type is exposed by the HtmlToPdfConverterPdfDocumentOptions property.

A tagged PDF is a PDF with a special structure which enhances the accessibility features available in the PDF viewers.

Code Sample - Auto Create an Accessible Tagged PDF

C#
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Http;

// Use Winnovative Namespace
using Winnovative.Pdf.Chromium;

namespace Winnovative_Chromium_AspNetDemo.Controllers.HTML_to_PDF
{
    public class Generate_Tagged_PdfController : Controller
    {
        public IActionResult Index()
        {
            return View();
        }

        [HttpPost]
        public ActionResult ConvertHtmlToPdf(IFormCollection collection)
        {
            // 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 = "fvDh8eDx4fHg4P/h8eLg/+Dj/+jo6Og=";

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

            // Enable the creation of a tagged PDF
            htmlToPdfConverter.PdfDocumentOptions.GenerateTaggedPdf = collection["generateTaggedPdfCheckBox"].Count > 0;

            byte[] outPdfBuffer = null;

            if (collection["HtmlPageSource"] == "convertHtmlRadioButton")
            {
                string htmlWithForm = collection["htmlStringTextBox"];
                string baseUrl = collection["baseUrlTextBox"];

                outPdfBuffer = htmlToPdfConverter.ConvertHtml(htmlWithForm, baseUrl);
            }
            else
            {
                string url = collection["urlTextBox"];

                outPdfBuffer = htmlToPdfConverter.ConvertUrl(url);
            }

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

            return fileResult;
        }
    }
}

See Also