Articles in this section
Category / Section

How to Export Individual Annotation from PDF in WinForms?

6 mins read

Syncfusion Essential PDF is a .NET PDF library used to create, read, and edit PDF documents. Using this library, you can export individual annotations in a PDF document to an FDF (Forms Data Format) or XFDF (XML Forms Data Format) file.

Steps to export individual annotations to an FDF file programmatically:

  1. Create a new C# console application project.

Create a console application in Visual Studio

  1. Install the Syncfusion.Pdf.WinForms NuGet package as a reference to your .NET framework application from NuGet.org.

Refer NuGet to the project

  1. Include the following namespaces in the Program.cs file.

C#

using Syncfusion.Pdf;
using Syncfusion.Pdf.Interactive;
using Syncfusion.Pdf.Parsing;

 

VB.NET

Imports Syncfusion.Pdf
Imports Syncfusion.Pdf.Interactive
Imports Syncfusion.Pdf.Parsing

 

  1. Use the following code snippet to export individual annotations from a PDF document. You can export the annotations using the ExportAnnotation method in the PdfLoadedDocument class.

C#

// Load PDF document to export
PdfLoadedDocument document = new PdfLoadedDocument(@"Input.pdf");

foreach (PdfLoadedPage loadedPage in document.Pages)
{
    for (int i = 0; i < loadedPage.Annotations.Count; i++)
    {
        // Get annotation
        PdfLoadedAnnotation annotation = loadedPage.Annotations[i] as PdfLoadedAnnotation;

        // Collection to export annotation
        PdfExportAnnotationCollection collection = new PdfExportAnnotationCollection();

        // Add annotation into collection
        collection.Add(annotation);

        // Export annotation into FDF format
        document.ExportAnnotations(@"Annotation" + i + ".fdf", AnnotationDataFormat.Fdf, collection);
    }
}
// Close the document
document.Close(true);

VB.NET

' Load PDF document
Dim document As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf")

For Each loadedPage As PdfLoadedPage In document.Pages
    For i As Integer = 0 To loadedPage.Annotations.Count - 1

        ' Get the annotation
        Dim annotation As PdfLoadedAnnotation = TryCast(loadedPage.Annotations(i), PdfLoadedAnnotation)

        ' Collection to export annotation
        Dim collection As PdfExportAnnotationCollection = New PdfExportAnnotationCollection()

        ' Add annotation to collection
        collection.Add(annotation)

        ' Export annotation into FDF format file
        document.ExportAnnotations("Annotation" & i & ".fdf", AnnotationDataFormat.Fdf, collection)

    Next
Next

' Close the document
document.Close(True);
A complete working sample can be downloaded from ExportAnnotationSample.zip.

Take a moment to peruse the documentation, where you will find other options like import annotation from FDF/XFDF file, adding annotation to PDF, modifying and removing annotation, save and retrieve the annotation from the data base with code example.

Click here to explore the rich set of Syncfusion Essential® PDF features.

 

Note:

Starting with v16.2.0.x, if you reference Syncfusion® assemblies from the trial setup or the NuGet feed, include a license key in your projects. Refer to the link to learn about generating and registering the Syncfusion® license key in your application to use the components without a trial message.


Conclusion

I hope you enjoyed learning about how to export individual annotations from a PDF in WinForms.

You can refer to our WinForms PDF feature tour page to learn about its other groundbreaking features and documentation, to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied