Create Tagged PDF using C#

Creating a Tagged PDF means adding (or creating) certain elements to the document that will enable the document to be validated in accordance with PDF/UA requirements. These elements are called often Structure Elements.

The following code snippet also work with Aspose.PDF.Drawing library.

Creating Tagged PDF (Simple Scenario)

In order to create structure elements in a Tagged PDF Document, Aspose.PDF offers methods to create structure element using ITaggedContent interface. Following code snippet shows how to create Tagged PDF which contain 2 elements: header and paragraph.

We will get a following document after creation:

Tagged PDF document with 2 elements - Header and Paragraph

Creating Tagged PDF with nested elements (Creating Structure Elements Tree)

In some cases, we need to create more complex sturcutre, eg. place quotes in paragraph. In order to create structure elements tree we should use AppendChild method. Following code snippet shows how to create structure elements tree of Tagged PDF Document:

We will get a following document after creation: Tagged PDF document with nested elements - span and quotes

Styling Text Structure

In order to style text structure in a Tagged PDF Document, Aspose.PDF offers Font, FontSize, FontStyle and ForegroundColor properties of StructureTextState Class. Following code snippet shows how to style text structure in a Tagged PDF Document:

Illustrating Structure Elements

In order to illustrate structure elements in a Tagged PDF Document, Aspose.PDF offers IllustrationElement class. Following code snippet shows how to illustrate structure elements in a Tagged PDF Document:

Validate Tagged PDF

Aspose.PDF for .NET provides the ability to validate PDF/UA Tagged PDF Document. Validation of PDF/UA standard supports:

  • Checks for XObjects.
  • Checks for Actions.
  • Checks for Optional Content.
  • Checks for Embedded Files.
  • Checks for Acroform Fields(Validate Natural Language and Alternate Name and Digital Signatures).
  • Checks for XFA Form Fields.
  • Checks for Security settings.
  • Checks for Navigation.
  • Checks for Annotations.

The code snippet below shows how to validate the Tagged PDF Document. Corresponding problems will be displayed in the XML log report.