VintaSoft Imaging .NET SDK 14.0: Documentation for .NET developer
Vintasoft.Imaging.Pdf.Tree.Annotations Namespace / PdfAnnotationXfdfCodec Class
Members Object Syntax Example Hierarchy Requirements SeeAlso
In This Topic
    PdfAnnotationXfdfCodec Class
    In This Topic
    Exports PDF annotations to XFDF format and imports PDF annotations from XFDF format.
    Object Model
    PdfAnnotationXfdfCodec
    Syntax
    'Declaration
    
    Public Class PdfAnnotationXfdfCodec
       Inherits PdfAnnotationCodec
    
    
    public class PdfAnnotationXfdfCodec : PdfAnnotationCodec
    
    
    public __gc class PdfAnnotationXfdfCodec : public PdfAnnotationCodec*
    
    
    public ref class PdfAnnotationXfdfCodec : public PdfAnnotationCodec^
    
    
    Example

    Here is an example that shows how to export/import PDF annotations of PDF document to/from file in XFDF format:

    
    ''' <summary>
    ''' Exports all PDF annotations of PDF document to the file in XFDF format.
    ''' </summary>
    ''' <param name="pdfFilename">The name of PDF file.</param>
    ''' <param name="xfdfFilename">The name of XFDF filen.</param>
    Public Shared Sub ExportPdfAnnotationsToXfdf(pdfFilename As String, xfdfFilename As String)
        ' open PDF document
        Using document As New Vintasoft.Imaging.Pdf.PdfDocument(pdfFilename)
            ' create XFDF codec
            Dim xfdfCodec As New Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationXfdfCodec()
    
            ' create file
            Using stream As System.IO.Stream = System.IO.File.Create(xfdfFilename)
                ' export all PDF annotations of PDF document to the file in XFDF format
                xfdfCodec.Export(document, stream)
            End Using
        End Using
    End Sub
    
    ''' <summary>
    ''' Imports the PDF annotations from XFDF format.
    ''' </summary>
    ''' <param name="pdfFilename">The name of PDF file.</param>
    ''' <param name="xfdfFilename">The name of XFDF file.</param>
    Public Shared Sub ImportPdfAnnotationsFromXfdf(pdfFilename As String, xfdfFilename As String)
        ' open PDF document
        Using document As New Vintasoft.Imaging.Pdf.PdfDocument(pdfFilename)
            ' create XFDF codec
            Dim xfdfCodec As New Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationXfdfCodec()
    
            ' open XFDF file
            Using stream As System.IO.Stream = System.IO.File.OpenRead(xfdfFilename)
                ' import the PDF annotations from XFDF file
                xfdfCodec.Import(document, stream)
            End Using
    
            ' save changes in PDF document
            document.SaveChanges()
        End Using
    End Sub
    
    
    
    /// <summary>
    /// Exports all PDF annotations of PDF document to the file in XFDF format.
    /// </summary>
    /// <param name="pdfFilename">The name of PDF file.</param>
    /// <param name="xfdfFilename">The name of XFDF filen.</param>
    public static void ExportPdfAnnotationsToXfdf(string pdfFilename, string xfdfFilename)
    {
        // open PDF document
        using (Vintasoft.Imaging.Pdf.PdfDocument document = new Vintasoft.Imaging.Pdf.PdfDocument(pdfFilename))
        {
            // create XFDF codec
            Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationXfdfCodec xfdfCodec =
                new Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationXfdfCodec();
    
            // create file
            using (System.IO.Stream stream = System.IO.File.Create(xfdfFilename))
            {
                // export all PDF annotations of PDF document to the file in XFDF format
                xfdfCodec.Export(document, stream);
            }
        }
    }
    
    /// <summary>
    /// Imports the PDF annotations from XFDF format.
    /// </summary>
    /// <param name="pdfFilename">The name of PDF file.</param>
    /// <param name="xfdfFilename">The name of XFDF file.</param>
    public static void ImportPdfAnnotationsFromXfdf(string pdfFilename, string xfdfFilename)
    {
        // open PDF document
        using (Vintasoft.Imaging.Pdf.PdfDocument document = new Vintasoft.Imaging.Pdf.PdfDocument(pdfFilename))
        {
            // create XFDF codec
            Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationXfdfCodec xfdfCodec =
                new Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationXfdfCodec();
    
            // open XFDF file
            using (System.IO.Stream stream = System.IO.File.OpenRead(xfdfFilename))
            {
                // import the PDF annotations from XFDF file
                xfdfCodec.Import(document, stream);
            }
    
            // save changes in PDF document
            document.SaveChanges();
        }
    }
    
    

    Inheritance Hierarchy

    System.Object
       Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationCodec
          Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationXfdfCodec

    Requirements

    Target Platforms: .NET9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    See Also