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
- Create a
Document
object. - Enable tagging by creating
TagOptions
and setting totrue
. - Create a
Page
object and add it to theDocument
instance. - Create an
Image
. - Create a
StructureElement
. - Set the
StructureElement
to the image. - Add the image to the
Page
instance. - Create a
PageNumberingLabel
. - Create an
Artifact
and set the type usingSetType
. - Set artifact to the
PageNumberingLabel
instance. - Add the
PageNumberingLabel
to thePage
instance. - 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.
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.
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
andLabel
), - 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.
- Java - DynamicPDF Generator for Java
- COM/ActiveX - DynamicPDF Generator for COM/ActiveX