Articles in this section
Category / Section

How to Check Whether PDF Documents Have Accessiblity Tags

3 mins read

A PDF file without accessible information is useless to people who need a screen reader and text-to-speech tool. Therefore, a need for creating accessible PDF files (usually referred to as tagged PDFs) arises.

Tagged PDF
The tagged PDF is a PDF file that includes structure in terms of tags that define reading order and the meaning of significant elements such as figures, images, lists, and tables. PDF tags provide a hidden-structured, textual representation of a PDF content presented to the screen readers. They exist only for accessibility purposes and have no visible effect on the PDF file.

Syncfusion Essential® PDF is a .NET PDF library used to create, read, and edit PDF documents. Using this library, you can check whether the PDF documents contain Accessibility tags.

Steps to check whether the PDF documents contain Accessibility tags or not programmatically

  1. Create a new C# console application project.
  2. Install the Syncfusion.Pdf.WinForms NuGet package as a reference to your .NET Framework application from NuGet.org.
  3. Include the following namespace in the Program.cs file.

C#

using Syncfusion.Pdf;
using Syncfusion.Pdf.Parsing;
using System;
using System.IO;

VB.NET

Imports Syncfusion.Pdf
Imports Syncfusion.Pdf.Parsing
Imports System
Imports System.IO
  1. Use the following code sample to check whether the PDF documents contain Accessibility tags.

C#

//Get the stream from the document.
FileStream documentStream = new FileStream("../../Input.pdf", FileMode.Open, FileAccess.Read);
//Load the existing PDF document.
PdfLoadedDocument document = new PdfLoadedDocument(documentStream);
//Get the structure element root from the document.
PdfStructureElement rootElement = document.StructureElement;
// Check if the root element is not null and if it has child elements.
if (rootElement != null && rootElement.ChildElements != null && rootElement.ChildElements.Length > 0)
{
   // Print a message indicating that the document contains accessibility tags.
   Console.WriteLine("The document have accessibility tags");
}
else
{
   // Print a message indicating that accessibility tags are not present in the document
   Console.WriteLine("Accessibility tags are not present in this document");
}

VB.NET

' Get the stream from the document.
Dim documentStream As New FileStream("../../Input.pdf", FileMode.Open, FileAccess.Read)
' Load the existing PDF document.
Dim document As New PdfLoadedDocument(documentStream)
' Get the structure element root from the document.
Dim rootElement As PdfStructureElement = document.StructureElement
' Check if the root element is not null and if it has child elements.
If rootElement IsNot Nothing AndAlso rootElement.ChildElements IsNot Nothing AndAlso rootElement.ChildElements.Length > 0 Then
   ' Print a message indicating that the document contains accessibility tags.
    Console.WriteLine("The document have accessibility tags")
Else
   ' Print a message indicating that accessibility tags are absent in the document.
    Console.WriteLine("Accessibility tags are not present in this document")
End If

Download the work sample from Check_accessiblity_tags.Zip

Take a moment to peruse the documentation, where you will find other options like adding tags to text elements, images, shapes, form fields, annotations, hyperlinks, template, table, and list element with code examples.

Refer here to explore the rich set of Syncfusion Essential® PDF features.

Note:
Starting with v16.2.0.x, if you reference Syncfusion® assemblies from the trial setup or the NuGet feed, include a license key in your projects. Refer to the link to learn about generating and registering the Syncfusion® license key in your application to use the components without a trail message.

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied