VintaSoft Imaging .NET SDK 14.0: Документация для .NET разработчика
Vintasoft.Imaging.Pdf.Tree.Annotations Namespace / PdfAnnotationXfdfCodec Class
Члены типа Объект Синтаксис Example Иерархия Требования Смотрите также
В этом разделе
    Класс PdfAnnotationXfdfCodec
    В этом разделе
    Экспортирует PDF-аннотации в формат XFDF и импортирует PDF-аннотации из формата XFDF.
    Объектная модель
    PdfAnnotationXfdfCodec
    Синтаксис
    'Declaration
    
    Public Class PdfAnnotationXfdfCodec
       Inherits PdfAnnotationCodec
    
    
    public class PdfAnnotationXfdfCodec : PdfAnnotationCodec
    
    
    public __gc class PdfAnnotationXfdfCodec : public PdfAnnotationCodec*
    
    
    public ref class PdfAnnotationXfdfCodec : public PdfAnnotationCodec^
    
    
    Пример

    Вот пример, показывающий, как экспортировать/импортировать PDF-PDF аннотации документа в/из файла в формате XFDF:

    
    ''' <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();
        }
    }
    
    

    Иерархия наследования

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

    Требования

    Целевые платформы: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    Смотрите также