---
title: "Create tagged PDF in C# .NET | Nutrient .NET SDK"
canonical_url: "https://www.nutrient.io/guides/dotnet/pdf-generation/tagged/"
md_url: "https://www.nutrient.io/guides/dotnet/pdf-generation/tagged.md"
last_updated: "2026-05-21T17:12:02.215Z"
description: "Learn how to create accessible and tagged PDF documents programmatically in C# using Nutrient .NET SDK. Improve PDF usability for assistive technologies."
---

# Create tagged PDFs in C#

This guide explains how to create a valid tagged PDF document from scratch. A tagged PDF has a logical structure that makes the document more accessible. For example, you can use tags to make PDF documents easier to process with screen reader software.

To create a tagged PDF document, follow these steps:

1. Create a `GdPicturePDF` object.

2. Set the measurement unit with the `SetMeasurementUnit` method. This method takes a member of the `PdfMeasurementUnit` enumeration as its parameter. For example, to set the unit of measurement to millimeters, call `gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)`.

3. Set the origin of the coordinate system with the `SetOrigin` method. This method takes a member of the `PdfOrigin` enumeration as its parameter. For example, to set the origin to the top-left corner, call `gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)`.

4. Create a new PDF document with the `NewPDF` method. Optionally, specify the conformance level with a member of the `PdfConformance` enumeration.

5. Add a new A4-sized page to the document with the `NewPage` method. This method takes a member of the `PdfPageSizes` enumeration as its parameter.

6. Set the font type to be used in the PDF document with the `AddTrueTypeFontU` method, and store the font resource name in a variable.

7. Set the font size in points with the `SetTextSize` method. For more information, see [Text Settings in PDFs](https://www.nutrient.io/guides/dotnet/editor/add-text-to-pdf.md).

8. Load the image to be used in the PDF document with the `AddJpegImageFromFile` method.

9. Set the title of the document with the `SetTitle` method. This title isn’t visually displayed in the document, but it’s required for some PDF conformance levels, such as PDF/UA.

10. Set the language with the `SetLanguage` method.

11. Determine the ID of the root tag with the `GetTagRootID` method.

12. Create a section tag for the document content with the `NewTag` method. This method takes the ID of the parent tag and the type of the newly created tag as its parameters. In this case, the type of the new tag is `Sect`.

13. Add text to the new section with the following methods:
    - Start adding marked content with the `BeginMarkedContentSequence` method. This method takes the ID of the parent tag and the type of the newly created marked content as its parameters. In this case, the type is `Span`.
    - Add text with the `DrawText` method. This method takes the following parameters: the variable for the font type, the coordinates specifying where to add the text, and the text to be added. You can define single-line or multiline text.
    - Finish adding marked content with the `EndMarkedContent` method.

14. Create a figure tag for the image with the `NewTag` method. This method takes the ID of the parent tag and the type of the newly created tag as its parameters. In this case, the type of the new tag is `Figure`.

15. Set an alternate description to the image with the `SetTagAlternateDescription` method.

16. Add the image to the new figure tag with the following methods:
    - Start adding marked content with the `BeginMarkedContentSequence` method. This method takes the ID of the parent tag and the type of the newly created marked content as its parameters. In this case, the type is `Figure`.
    - Add the image with the `DrawImage` method. This method takes the following parameters: the image ID, the coordinates of the image’s closest point to the origin, and the width and the height of the image. The coordinates and the lengths are relative to the origin and expressed in the measurement unit defined above.
    - Finish adding marked content with the `EndMarkedContent` method.

17. Save the output in a PDF document with the `SaveToFile` method.

The example below creates a tagged PDF document with some text and an image:

### C#

```csharp

using GdPicturePDF gdpicturePDF = new GdPicturePDF();
// Set the measurement unit and the origin.
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
// Create a new PDF document.
gdpicturePDF.NewPDF();
// Add a new A4-sized page to the document.
gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4);
// Set the font and the font size to be used in the PDF document.
string fontResourceName = gdpicturePDF.AddTrueTypeFontU("Arial", false, false, true);
gdpicturePDF.SetTextSize(18);
// Load the image to be used in the PDF document.
string logo = gdpicturePDF.AddJpegImageFromFile(@"C:\temp\logo.jpg");
// Set the title.
gdpicturePDF.SetTitle("Company Logo");
// Set the language.
gdpicturePDF.SetLanguage("en-US");
// Determine the ID of the root tag.
int tagRootId = gdpicturePDF.GetTagRootID();
// Create a section tag for the document content.
int tagSection = gdpicturePDF.NewTag(tagRootId, "Sect");
// Add text to the section.
gdpicturePDF.BeginMarkedContentSequence(tagSection, "Span");
gdpicturePDF.DrawText(fontResourceName, 20, 60, "The company logo is");
gdpicturePDF.EndMarkedContent();
// Create a figure tag within the section and set its properties.
int tagLogo = gdpicturePDF.NewTag(tagSection, "Figure");
gdpicturePDF.SetTagAlternateDescription(tagLogo, "This is the company logo.");
// Add the image to the figure tag.
gdpicturePDF.BeginMarkedContentSequence(tagLogo, "Figure");
gdpicturePDF.DrawImage(logo, 80, 80, 40, 40);
gdpicturePDF.EndMarkedContent();
// Save the output in a PDF document.
gdpicturePDF.SaveToFile(@"C:\temp\output.pdf");

```

### VB.NET

```vb

Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
    ' Set the measurement unit and the origin.
    gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
    gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
    ' Create a new PDF document.
    gdpicturePDF.NewPDF()
    ' Add a new A4-sized page to the document.
    gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4)
    ' Set the font and the font size to be used in the PDF document.
    Dim fontResourceName As String = gdpicturePDF.AddTrueTypeFontU("Arial", False, False, True)
    gdpicturePDF.SetTextSize(18)
    ' Load the image to be used in the PDF document.
    Dim logo As String = gdpicturePDF.AddJpegImageFromFile("C:\temp\logo.jpg")
    ' Set the title.
    gdpicturePDF.SetTitle("Company Logo")
    ' Set the language.
    gdpicturePDF.SetLanguage("en-US")
    ' Determine the ID of the root tag.
    Dim tagRootId As Integer = gdpicturePDF.GetTagRootID()
    ' Create a section tag for the document content.
    Dim tagSection As Integer = gdpicturePDF.NewTag(tagRootId, "Sect")
    ' Add text to the section.
    gdpicturePDF.BeginMarkedContentSequence(tagSection, "Span")
    gdpicturePDF.DrawText(fontResourceName, 20, 60, "The company logo is")
    gdpicturePDF.EndMarkedContent()
    ' Create a figure tag within the section and set its properties.
    Dim tagLogo As Integer = gdpicturePDF.NewTag(tagSection, "Figure")
    gdpicturePDF.SetTagAlternateDescription(tagLogo, "This is the company logo.")
    ' Add the image to the figure tag.
    gdpicturePDF.BeginMarkedContentSequence(tagLogo, "Figure")
    gdpicturePDF.DrawImage(logo, 80, 80, 40, 40)
    gdpicturePDF.EndMarkedContent()
    ' Save the output in a PDF document.
    gdpicturePDF.SaveToFile("C:\temp\output.pdf")
End Using

```

#### Used methods

- [`AddJpegImageFromFile`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~AddJpegImageFromFile.html)

- [`AddStandardFont`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~AddStandardFont.html)

- [`BeginMarkedContentSequence`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~BeginMarkedContentSequence.html)

- [`DrawImage`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~DrawImage.html)

- [`DrawText`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~DrawText.html)

- [`EndMarkedContent`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~EndMarkedContent.html)

- [`GetTagRootID`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~GetTagRootID.html)

- [`NewPage`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~NewPage.html)

- [`NewPDF`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~NewPDF.html)

- [`NewTag`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~NewTag.html)

- [`SetLanguage`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~SetLanguage.html)

- [`SetMeasurementUnit`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~SetMeasurementUnit.html)

- [`SetOrigin`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~SetOrigin.html)

- [`SetTagAlternateDescription`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~SetTagAlternateDescription.html)

- [`SetTextSize`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~SetTextSize.html)

- [`SetTitle`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~SetTitle.html)

- [`SaveToFile`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~SaveToFile.html)

#### Related topics

- [Load a file](/guides/dotnet/load-a-file.md)

- [Save a file](/guides/dotnet/save-a-file.md)
---

## Related pages

- [Create PDFs from byte arrays in C#](/guides/dotnet/pdf-generation/byte-array.md)
- [Generate a PDF from HTML in C#](/guides/dotnet/pdf-generation/from-html.md)
- [Generate PDFs in.NET](/guides/dotnet/pdf-generation.md)
- [Create PDFs from scratch in C#](/guides/dotnet/pdf-generation/from-scratch.md)
- [Create thumbnails from PDFs in C#](/guides/dotnet/pdf-generation/thumbnail-preview.md)
- [Generate a PDF from a DOCX template in C#](/guides/dotnet/pdf-generation/from-word-template.md)

