Examples

Create Tagged PDF

Creating a tagged PDF using DynamicPDF Core Suite is straightforward.

How to Create a Tagged PDF in C#

The following steps and sample code illustrates creating a tagged PDF document using DynamicPDF Core Suite.

Steps for creating a Tagged PDF Document

  1. Create a Document object.
  2. Enable tagging by creating TagOptions and setting to true.
  3. Create a Page object and add it to the Document instance.
  4. Create an Image.
  5. Create a StructureElement.
  6. Set the StructureElement to the image.
  7. Add the image to the Page instance.
  8. Create a PageNumberingLabel.
  9. Create an Artifact and set the type using SetType.
  10. Set artifact to the PageNumberingLabel instance.
  11. Add the PageNumberingLabel to the Page instance.
  12. Save the PDF document.

Sample Code - C#

Document document = new Document();
document.Tag = new TagOptions(true);

Page page = new Page();
document.Pages.Add( page );

Image image = new Image("DPDFLogo.png", 180f, 150f, 0.24f);
image.Height = 200;
image.Width = 200;

StructureElement imageStructureElement = new StructureElement(TagType.Figure);
imageStructureElement.IncludeDefaultAttributes = true;
imageStructureElement.AlternateText = "DynamicPDF Logo";

image.Tag = imageStructureElement;
page.Elements.Add(image);
PageNumberingLabel pageNumberingLabel = new PageNumberingLabel("Page %%CP%% of %%TP%%", 0, 680, 512, 12, Font.Helvetica, 12, TextAlign.Center);

Artifact artifact = new Artifact();
artifact.SetType(ArtifactType.Pagination);
pageNumberingLabel.Tag = artifact;
page.Elements.Add(pageNumberingLabel);

document.Draw( "output.pdf" );

GitHub Project

Clone or view the example project at GitHub. This example code is contained in the Examples/TaggedPdfExample.cs file.

Clone or View Example Project on GitHub

Getting Started

NuGet Package

DynamicPDF Core Suite is available on NuGet and is part of the ceTe.DynamicPDF.CoreSuite.NET package. The easiest way to install the package is through the Visual Studio Package Manger. You can also download the package directly from NuGet.

NuGet Package ID: ceTe.DynamicPDF.CoreSuite.NET

DynamicPDF Core Suite Information

DynamicPDF Core Suite contains over 75 page elements you can use to add rich content to PDFs you create. DynamicPDF Core Suite includes elements for:

  • Images,
  • Text Objects (TextArea and Label),
  • HTML,
  • Barcodes (47 types),
  • Form Fields,
  • and Charts.

More information on DynamicPDF Core Suite can be found online.

Available on Other platforms

DynamicPDF Core Suite is also available for the Java and COM/ActiveX platforms. Refer to the respective product pages for more details.

Why Choose DynamicPDF?

  • Transparent Pricing
  • Lots of Features
  • Easy to Use
  • Great Support
  • Efficient Performance
  • Product Maturity (Over 22 Years)
  • Free Evaluation
  • .NET Core Support (Most Products)
  • Flexible Licensing

We’re Not The Only Ones That Think We’re Great!