A PDF file without accessible information is of no use to the people who need a screen reader and text-to-speech tool. Therefore, a need for creating accessible PDF files (usually referred to as a tagged PDFs) arises. The tagged PDF is a PDF file that includes structure in terms of tags that defines reading order and the meaning of significant elements such as figures, images, lists, tables, etc.
PDF tags provide a hidden-structured, textual representation of the PDF content that is presented to the screen readers. They exist only for accessibility purposes and have no visible effect on the PDF file. In the PDF file, it is not guaranteed that the content displaying order is the same as the physical order of objects within the PDF’s content stream. Some of the screen readers may use physical order to read-aloud the content. Here, the tags will help the screen reader to provide the correct reading order and experience to people with disabilities.
The Essential PDF library provides the ability to create accessible PDF files from the version 15.3.0.26 onwards via the tagged PDF feature. PDF documents created using the Essential PDF library are compliant with section 508 (PDF/UA). Essential PDF supports adding tags to PDF elements such as text, image, shapes, form fields, annotations, hyperlinks, tables, lists, etc.
Also, it supports the automatic addition of respective tags for each element, if the AutoTag property of PdfDocument class is set to true. But it will not add alternative text or descriptions for figures, images, and other properties related to the tag.
To pass the full check of accessibility, you should follow the below conventions while tagging the PDF document:
The below code snippet is used to create a simple tagged PDF. A runnable sample can be downloaded from this link.
///Create a new PDF document instance. PdfDocument doc = new PdfDocument(); //Set the document title in document properties. doc.DocumentInformation.Title = "Tagged PDF"; //Enables the automatic adding of respective PDF tags for each element. doc.AutoTag = true; //Add a new PDF page. PdfPage page = doc.Pages.Add(); //Create PDF True Type font instance. PdfTrueTypeFont tFont16 = new PdfTrueTypeFont(new System.Drawing.Font("Calibri", 16), true); PdfTrueTypeFont tFont11 = new PdfTrueTypeFont(new System.Drawing.Font("Calibri", 11), FontStyle.Regular, 11, true, true); //Create new PDF solid brush. PdfBrush headerBrush = new PdfSolidBrush(Color.Blue); //Create PDF layout format. PdfLayoutFormat format = new PdfLayoutFormat(); format.Layout = PdfLayoutType.Paginate; //Initialize the structure element with tag type Heading level. PdfStructureElement headingTag = new PdfStructureElement(PdfTagType.HeadingLevel1); //Create a header text. PdfTextElement element = new PdfTextElement("Chapter 1 – Text & Image", tFont16); //Setting heading level to differentiate it from paragraphs. By default, all the textual contents are tagged as paragraphs. element.PdfTag = headingTag; //Create a solid brush. element.Brush = headerBrush; //Draw the text element. PdfLayoutResult result = element.Draw(page, PointF.Empty, format); PdfTextElement element1 = new PdfTextElement("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", tFont11); result = element1.Draw(result.Page, new RectangleF(new PointF(0, result.Bounds.Bottom + 10), result.Page.GetClientSize()), format); //Create a new PDF Bitmap. PdfBitmap image = new PdfBitmap("../../adv.jpg"); //Set the tag type for image. PdfStructureElement imageElement = new PdfStructureElement(PdfTagType.Figure); //Set the alternate text. imageElement.AlternateText = "Adventure cycle"; //Adding tag to the PDF image. image.PdfTag = imageElement; result = image.Draw(result.Page, new RectangleF(0, result.Bounds.Bottom + 10, result.Page.GetClientSize().Width, (result.Page.GetClientSize().Height - result.Bounds.Bottom + 10)), format); //Save the PDF document. doc.Save("output.pdf"); //Close the PDF document. doc.Close(true);
If you are new to our PDF library, it is highly recommended to go through the getting started section. For information on how to create a tagged PDF, please refer to this link.
Soon, the ability to modify the tab order in an existing tagged PDF document and the ability to create a tagged PDF while converting Word, Excel, and PowerPoint files to PDF files will be supported.
If you have any questions or require clarification about this support, please let us know in the comments below. You can also contact us through our support forum or Direct Trac. We are happy to assist you!