我需要一个示例代码或代码来读取和写入注释以及返回到新 pdf 文档的状态?
i need a sample code or code to read and write annotations along with status back to a new pdf doc?
我需要将注释状态写回升级后的新pdf。下面是我为此使用的代码。
我试过 Syncfusion 测试版 17.0
PdfLoadedDocument docSource = new PdfLoadedDocument(@"D:\Output1_annotaions.pdf");
PdfLoadedDocument docDestination = new PdfLoadedDocument(@"D:\Output1.pdf");
//Get annotations of first page and read destination of first page
PdfLoadedPage pageDestination = docDestination.Pages[0] as PdfLoadedPage;
PdfLoadedPage pageSource = docSource.Pages[0] as PdfLoadedPage;
//Get annotation objects
PdfLoadedAnnotationCollection annotations = pageSource.Annotations;
//loop through annotation objects
foreach (var item in annotations)
{
pageDestination.Annotations.Add((PdfAnnotation)item);
}
//Save destination document
docDestination.Save(@"D:\Output1.pdf");
//close the documents
docDestination.Close(true);
docSource.Close(true);
我需要使用 syncfusion 编写从一个版本的 pdf 到较新版本的 pdf 的所有注释以及注释的状态嵌套回复。
您使用的代码示例不会将源 PDF 中存在的所有注释完全导入目标 PDF。为了将注释从一个文档导入到另一个文档,您可以使用以下代码示例:
///Loads the source and destination PDF
PdfLoadedDocument sourcePDF = new PdfLoadedDocument(DataPathBase+"Input.pdf");
PdfLoadedDocument destinationPDF = new PdfLoadedDocument(DataPathBase+"sample.pdf");
string xfdfFilePath = DataPathOutput + "Export_.xfdf";
//Export annotation data to XFDF file
sourcePDF.ExportAnnotations(xfdfFilePath, AnnotationDataFormat.XFdf);
//Import annotation data from XFDF file
destinationPDF.ImportAnnotations(xfdfFilePath, AnnotationDataFormat.XFdf);
//Save imported PDF document
destinationPDF.Save(DataPathOutput+"Output.pdf");
//close the documents
destinationPDF.Close(true);
sourcePDF.Close(true);
同样可以参考下面的UG文档:
https://help.syncfusion.com/file-formats/pdf/working-with-annotations#importing-annotations-from-xfdf-file
但是,使用此代码无法在某些 PDF 文档中正确导入带有状态的注释。这已确认为缺陷,此问题的修复程序将包含在我们的 2019 Volume 1 SP1 版本中,该版本暂定于 2019 年 4 月推出。
可以使用以下 link 跟踪此问题修复的状态。
https://www.syncfusion.com/feedback/5430/status-and-layer-is-not-preserved-in-resultant-pdf-while-importing-annotation-from-xfdf
注意:我为 Syncfusion 工作。
此致,
迪利巴布。
我需要将注释状态写回升级后的新pdf。下面是我为此使用的代码。
我试过 Syncfusion 测试版 17.0
PdfLoadedDocument docSource = new PdfLoadedDocument(@"D:\Output1_annotaions.pdf");
PdfLoadedDocument docDestination = new PdfLoadedDocument(@"D:\Output1.pdf");
//Get annotations of first page and read destination of first page
PdfLoadedPage pageDestination = docDestination.Pages[0] as PdfLoadedPage;
PdfLoadedPage pageSource = docSource.Pages[0] as PdfLoadedPage;
//Get annotation objects
PdfLoadedAnnotationCollection annotations = pageSource.Annotations;
//loop through annotation objects
foreach (var item in annotations)
{
pageDestination.Annotations.Add((PdfAnnotation)item);
}
//Save destination document
docDestination.Save(@"D:\Output1.pdf");
//close the documents
docDestination.Close(true);
docSource.Close(true);
我需要使用 syncfusion 编写从一个版本的 pdf 到较新版本的 pdf 的所有注释以及注释的状态嵌套回复。
您使用的代码示例不会将源 PDF 中存在的所有注释完全导入目标 PDF。为了将注释从一个文档导入到另一个文档,您可以使用以下代码示例:
///Loads the source and destination PDF
PdfLoadedDocument sourcePDF = new PdfLoadedDocument(DataPathBase+"Input.pdf");
PdfLoadedDocument destinationPDF = new PdfLoadedDocument(DataPathBase+"sample.pdf");
string xfdfFilePath = DataPathOutput + "Export_.xfdf";
//Export annotation data to XFDF file
sourcePDF.ExportAnnotations(xfdfFilePath, AnnotationDataFormat.XFdf);
//Import annotation data from XFDF file
destinationPDF.ImportAnnotations(xfdfFilePath, AnnotationDataFormat.XFdf);
//Save imported PDF document
destinationPDF.Save(DataPathOutput+"Output.pdf");
//close the documents
destinationPDF.Close(true);
sourcePDF.Close(true);
同样可以参考下面的UG文档: https://help.syncfusion.com/file-formats/pdf/working-with-annotations#importing-annotations-from-xfdf-file
但是,使用此代码无法在某些 PDF 文档中正确导入带有状态的注释。这已确认为缺陷,此问题的修复程序将包含在我们的 2019 Volume 1 SP1 版本中,该版本暂定于 2019 年 4 月推出。
可以使用以下 link 跟踪此问题修复的状态。 https://www.syncfusion.com/feedback/5430/status-and-layer-is-not-preserved-in-resultant-pdf-while-importing-annotation-from-xfdf
注意:我为 Syncfusion 工作。
此致,
迪利巴布。