Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Aspose.PDF for .NET es un componente rico en características cuando se trata de editar documentos PDF. Como sabemos, XFDF es un aspecto importante de la manipulación de formularios PDF, el espacio de nombres Aspose.Pdf.Facades en Aspose.PDF for .NET ha considerado esto muy bien y ha proporcionado métodos para importar y exportar datos de anotaciones a archivos XFDF.
La clase PDFAnnotationEditor contiene dos métodos para trabajar con la importación y exportación de anotaciones a un archivo XFDF. El método ExportAnnotationsXfdf proporciona la funcionalidad para exportar anotaciones de un documento PDF a un archivo XFDF, mientras que el método ImportAnnotationFromXfdf permite importar anotaciones de un archivo XFDF existente. Para importar o exportar anotaciones, necesitamos especificar los tipos de anotaciones. Podemos especificar estos tipos en forma de una enumeración y luego pasar esta enumeración como un argumento a cualquiera de estos métodos. De esta manera, solo se importarán o exportarán las anotaciones de los tipos especificados a un archivo XFDF.
El siguiente fragmento de código también funciona con la biblioteca Aspose.PDF.Drawing.
El siguiente fragmento de código muestra cómo exportar anotaciones a un archivo XFDF:
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void ExportAnnotationsToXfdf()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();
// Create PdfAnnotationEditor object
using (var annotationEditor = new Aspose.Pdf.Facades.PdfAnnotationEditor())
{
// Bind PDF document
annotationEditor.BindPdf(dataDir + "AnnotationDemo1.pdf");
// Define the annotation types to export
var annotType = new Aspose.Pdf.Annotations.AnnotationType[] { Aspose.Pdf.Annotations.AnnotationType.Line, Aspose.Pdf.Annotations.AnnotationType.Square };
// Export annotations to XFDF file
using (var fileStream = File.OpenWrite(dataDir + "exportannotations_out.xfdf"))
{
annotationEditor.ExportAnnotationsXfdf(fileStream, 1, 1, annotType);
fileStream.Flush();
}
}
}
El siguiente fragmento de código describe cómo importar anotaciones de un archivo XFDF:
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void ImportAnnotationFromXfdf()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();
// Create PdfAnnotationEditor object
using (var annotationEditor = new Aspose.Pdf.Facades.PdfAnnotationEditor())
{
// Create PDF document
using (var document = new Aspose.Pdf.Document())
{
// Add page
var page = document.Pages.Add();
// Bind PDF document
annotationEditor.BindPdf(document);
// Define the export file name
var exportFileName = dataDir + "exportannotations.xfdf";
// Import annotations from the XFDF file
annotationEditor.ImportAnnotationsFromXfdf(exportFileName);
// Save PDF document
document.Save(dataDir + "ImportAnnotationFromXfdf_out.pdf");
}
}
}
En el código a continuación, un método ImportAnnotations permite importar anotaciones directamente desde otro documento PDF.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void ImportAnnotationFromPDF()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();
// Open PDF document
using (var documentFrom = new Aspose.Pdf.Document(dataDir + "some_doc.pdf"))
{
// Create PDF document
using (var documentTo = new Aspose.Pdf.Document())
{
// Add page
var page = documentTo.Pages.Add();
// Export/import
using (var ms = new MemoryStream())
{
documentFrom.ExportAnnotationsToXfdf(ms);
documentTo.ImportAnnotationsFromXfdf(ms);
}
// Save PDF document
documentTo.Save(dataDir + "AnnotationDemo3_out.pdf");
}
}
}
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.