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 works 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 elements using the ITaggedContent interface. Following code snippet shows how to create Tagged PDF which contains 2 elements: header and paragraph.

We will get the 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 structure, 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 the following document after creation: Tagged PDF document with nested elements - span and quotes

Styling Text Structure

In order to style the text structure in a Tagged PDF Document, Aspose.PDF offers the Font, FontSize, FontStyle and ForegroundColor properties of the 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 a 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.

Adjust position of Text Structure

The following code snippet shows how to adjust Text Structure position in the Tagged PDF document:

Creating Tagged PDF automatically with PDF/UA-1 conversion

Aspose.PDF enables the automatic generation of basic logical structure markup when converting a document to PDF/UA-1. Users may then manually improve upon this basic logical structure, providing additional insights regarding the document contents.

To generate a logical document structure, create an instance of the Aspose.Pdf.AutoTaggingSettings class, set its AutoTaggingSettings.EnableAutoTagging property to true, and assign it to the PdfFormatConversionOptions.AutoTaggingSettings property.