Import XFDF annotation data to PDFs in C# .NET
XFDF
An XML Forms Data Format (XFDF) file stores data from annotations located in PDF documents. It contains the annotation structure and the values submitted to it.
Importing XFXF data from a file
To import the annotation data from a file, use the ImportXFDFDataFromFile
method with the following required parameters:
FilePath
— The file path of the XFDF file.ImportFormFields
— A Boolean value that specifies whether to import the form field data.ImportAnnotations
— A Boolean value that specifies whether to import the annotation data.
The example below imports a PDF annotation from an XFDF file:
using GdPicturePDF gdpicturePDF = new GdPicturePDF();gdpicturePDF.LoadFromFile(@"C:\temp\source.pdf");gdpicturePDF.ImportXFDFDataFromFile(@"C:\temp\annotation.xfdf", true, true);gdpicturePDF.SaveToFile(@"C:\temp\output.pdf");
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF() gdpicturePDF.LoadFromFile("C:\temp\source.pdf") gdpicturePDF.ImportXFDFDataFromFile("C:\temp\annotation.xfdf", True, True) gdpicturePDF.SaveToFile("C:\temp\output.pdf")End Using
Used methods
Related topics
Importing XFXF data from a database
To import the annotation data from a database, save the XFDF information from the database as a Stream
object, and then use the ImportXFDFDataFromStream
method with the following required parameters:
Stream
— TheStream
object containing XFDF information.ImportFormFields
— A Boolean value that specifies whether to import the form field data.ImportAnnotations
— A Boolean value that specifies whether to import the annotation data.
The example below imports a PDF annotation from a Stream
object containing XFDF information:
using GdPicturePDF gdpicturePDF = new GdPicturePDF();gdpicturePDF.LoadFromFile(@"C:\temp\source.pdf");gdpicturePDF.ImportXFDFDataFromStream(XFDFStream, true, true);gdpicturePDF.SaveToFile(@"C:\temp\output.pdf");
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF() gdpicturePDF.LoadFromFile("C:\temp\source.pdf") gdpicturePDF.ImportXFDFDataFromStream(XFDFStream, True, True) gdpicturePDF.SaveToFile("C:\temp\output.pdf")End Using
Used methods
Related topics