Syncfusion Feedback

Add Annotations to PDFs in C# with .NET PDF Library

The ® .NET PDF Library offers powerful capabilities for creating, reading, and editing PDF documents. Users can add and manage PDF annotations, enabling enhanced document interaction, clear communication, and improved content review workflows.

Watch this video to see how to add PDF annotations using the Syncfusion .NET PDF Library.

Watch the video

Add annotations to PDF documents in C#

Learn how to programmatically add interactive annotations (comments, highlights, stamps) to PDF documents in C# using the Syncfusion .NET PDF Library. This guide demonstrates PDF annotation creation and customization.

Step 1: Create a new C# Console Application project

Begin by creating a new C# Console Application project in Visual Studio or your preferred IDE to implement PDF annotation functionality.

Step 2: Install Syncfusion PDF NuGet package

Install the Syncfusion.Pdf.Net.Core NuGet package in your C# project from NuGet.org. This package provides APIs for creating and managing PDF annotations.

Step 3: Add required namespaces for PDF annotations

Import the following namespaces in your Program.cs file to access PDF annotation classes and interactive elements:

using Syncfusion.Drawing;
using Syncfusion.Pdf;
using Syncfusion.Pdf.Graphics;
using Syncfusion.Pdf.Interactive;
using Syncfusion.Pdf.Parsing;

Step 4: Load the PDF document and get the page

Use the PdfLoadedDocument class to load your existing PDF file where you want to add interactive annotations. Access the first page of the document where you want to add the annotation.

//Load the PDF document
using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(Path.GetFullPath(@"Data/Input.pdf")))
{
    //Get the first page of the PDF document
    PdfPageBase loadedPage = loadedDocument.Pages[0];
}

Step 5: Create a popup annotation and add to the page

Create a new PdfPopupAnnotation object with the position and text content. Customize the annotation appearance by setting the icon and color properties. Add the configured annotation to the page’s annotations collection.

Run

//Create a new popup annotation
PdfPopupAnnotation popupAnnotation = new PdfPopupAnnotation(new RectangleF(100, 100, 20, 20), "popup annotation");
//Set the icon for the popup annotation
popupAnnotation.Icon = PdfPopupIcon.Comment;
//Set the color for the pop-up annotation
popupAnnotation.Color = new PdfColor(Color.Yellow);
//Add the annotation to the page
loadedPage.Annotations.Add(popupAnnotation);

Step 6: Save the PDF document

Save the PDF document with the new interactive annotation using the Save method.

//Save the PDF document
loadedDocument.Save(Path.GetFullPath(@"Output/Output.pdf"));

NuGet installation

Nuget Installation image Syncfusion.Pdf.Net.Core Copy Icon image

Get started quickly by downloading the installer and checking license information on the Downloads page.

Syncfusion .NET PDF Library Resources

Explore these resources for comprehensive guides, knowledge base articles, insightful blogs, and ebooks.