Click or drag to resize

Tagged PDF and Accessibility (PDF/UA)

A tagged PDF carries the logical structure of the document - headings, paragraphs, lists, tables, figures with their alternate text, links, and the reading order - next to its visual content. Screen readers and other assistive technology use it, and it is required for accessible documents (PDF/UA, ISO 14289) and for PDF/A-3a.

Tagged PDF from HTML

Set Tagged to true and use the Chromium or Blink rendering engine. The structure comes from the HTML itself: write semantic HTML (h1-h6, p, ul/ol, table with th, img with alt, a with text) and the PDF gets the matching structure. Language sets the document language (en-US by default). PDF/UA also needs a document title.

PdfConverter converter = new PdfConverter();
converter.RenderingEngine = RenderingEngine.Chromium;
converter.Tagged = true;
converter.Language = "en-US";
converter.PdfDocumentInfo.Title = "Accessible report";
converter.SavePdfFromUrlToFile("https://www.example.com/report", "accessible-report.pdf");

Headers and footers are tagged as artifacts (decorative content that is not read). For a PDF/A-3a document, also set PdfStandardSubset = PdfStandardSubset.Pdf_A_3a. The WebKit engines cannot produce a tagged document: with Tagged = true they report an error.

Tagged documents built in code

When you build or extend a Document yourself, set Tagged and say how every element you add is tagged:

  • TagType - the structure type of real content (PdfTagType: Paragraph, Heading1, Figure, Table...).

  • AlternateText - the description of a figure, read instead of it.

  • ActualText - the text of content drawn as graphics.

  • Artifact - decorative content (rules, backgrounds, page numbers), left out of the structure.

  • BeginTag(PdfTagType) and EndTag - group elements in containers (Section, List, Table...).

An element added to a tagged document without a TagType and not marked as an Artifact is refused, so nothing ends up outside the structure by mistake. Link elements and HTML elements rendered with Chromium or Blink tag themselves.

Document document = new Document();
document.Tagged = true;
document.Language = "en-US";
document.DocumentInformation.Title = "Tagged document";

PdfPage page = document.AddPage();
PdfFont titleFont = document.AddFont(new System.Drawing.Font("Arial", 20, System.Drawing.FontStyle.Bold), true);
PdfFont textFont = document.AddFont(new System.Drawing.Font("Arial", 11), true);

document.BeginTag(PdfTagType.Section);

TextElement title = new TextElement(0, 0, "Quarterly results", titleFont);
title.TagType = PdfTagType.Heading1;
page.AddElement(title);

TextElement paragraph = new TextElement(0, 40, "Sales grew in every region.", textFont);
paragraph.TagType = PdfTagType.Paragraph;
page.AddElement(paragraph);

// a decorative rule: not part of the structure
RectangleElement rule = new RectangleElement(0, 30, 300, 1);
rule.Artifact = true;
page.AddElement(rule);

document.EndTag();
document.Save("tagged.pdf");
document.Close();
See Also