Create Tagged PDF (.NET Core/Framework)
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 to true. - Create a
Page
object and add it to the Document instance. - Create an
Image
. - Create a
StructureElement
. - Set the StructureElement to the image.
- Add the image to the Page instance.
- Create a Page numbering label.
- Create a artifact and add type.
- Set artifact to the page numbering label.
- Add the page numbering label to the Page 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" );
Over 75 Page Elements
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.
Getting Started
NuGet Package
DynamicPDF Generator 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
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