How to Convert PDF to Tagged PDF using C#

This how-to guide explains the process of how to convert PDF to tagged PDF using C#. It contains the details about setting the development environment to use Aspose.PDF library, a list of tasks to be accomplished while writing the application, and a runnable sample code for adding tags to PDF files using C#. This sample code for tagging PDF can be executed in any platform supporting .NET environment.

Steps to Create Tagged PDF using C#

  1. Establish the environment to use Aspose.PDF for .NET to create tagged PDF
  2. Create a PDF document and access reference to the tagged content in it
  3. Set the title and language for the tagged contents
  4. Create a header and a paragraph element and set text for both the elements
  5. Append this header and paragraph to the root element of the tagged content
  6. Save the tagged PDF on the disk

The aforementioned steps summarize the process for tagging PDF documents using C#. Each PDF document contains a property called TaggedContent that is used by setting its title and language followed by creating header and paragraph elements, however, you may create other elements as well by setting their respective properties. In the final step, the customized header and paragraph are appended to the RootElement in the ITaggedContent interface class before saving it on the disk.

Code to Tag PDF Files using C#

This code demonstrates how to add tags to PDF files using C#. In this sample code, we have created a header and paragraph, however, you may create other elements by using different methods, for instance, CreateAnnotElement(), CreateArtElement(), CreateCaptionElement(), CreateFigureElement(), and CreateFormElement() to list a few. Each element contains different properties for example, ActualText, AlternateDescriptions, AlternativeText, and ExpansionText along with many others that can be set as per the requirements.

This article has taught us how to add tags to PDF using C#. If you are interested in adding hyperlinks to a PDF, refer to the article on how to add hyperlink in PDF using C#.

 English