翻譯|使用教程|編輯:李顯亮|2020-11-13 10:10:39.743|閱讀 247 次
概述:在PDF文件中,注釋經常使用,可能需要將其導入或導出為XFDF格式。在本文中將介紹如何使用C#或VB.NET輕松地以編程方式導入或導出注釋。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
注釋通常用于向某些文檔添加說明,解釋,詳細信息或注釋。在PDF文件中,注釋經常使用,您可能需要將其導入或導出為XFDF格式在本文中將介紹如何使用C#或VB.NET輕松地以編程方式導入或導出注釋。讓我們看一下以下內容:
(安裝包僅提供部分功能,并設置限制,如需試用完整功能請。)
使用C#或VB.NET將注釋從XFDF導入到PDF
可以使用C#或VB.NET編程語言從基于.NET的應用程序中的現有XFDF文件將注釋導入PDF文件。API支持導入API參考中AnnotationType枚舉下列出的不同類型的注釋。讓我們按照以下步驟在基于.NET Framework的應用程序中使用C#或VB.NET編程語言將注釋從XFDF導入PDF。
下面的代碼段顯示了如何使用C#或VB.NET將注釋從XFDF文件導入PDF文件:
// Create an object of PdfAnnotationEditor class PdfAnnotationEditor editor = new PdfAnnotationEditor(); // Bind input PDF file editor.BindPdf(dataDir + "inFile.pdf"); // Create a file stream for input XFDF file to import annotations FileStream fileStream = new FileStream(dataDir + "exportannotations.xfdf", FileMode.Open, FileAccess.Read); // Create an enumeration of all the annotation types which you want to import Enum[] annType = { AnnotationType.Text }; // Import annotations of specified type(s) from XFDF file editor.ImportAnnotationFromXfdf(fileStream, annType); // Save output pdf file editor.Save(dataDir + "ImportAnnotations_out.pdf");
使用C#或VB.NET將注釋從PDF導出到XFDF文件
從PDF文件導出注釋有助于使文件可顯示或僅使特定類型的注釋保持完整。例如,當某人正在審查可行性報告或論文提交時,讓我們假設,他們可能會突出顯示某些文本,添加評論或文本。后來,他們只想保留文本,然后再將PDF發送回作者。在這種情況下,將注釋導出到XFDF會有所幫助,因為它使您可以根據需要導出特定的注釋。以下步驟顯示了如何將注釋從PDF導出為XFDF格式:
下面的代碼段顯示了如何使用C#或VB.NET將注釋從PDF文件導出到XFDF文件:
// Create an object of PdfAnnotationEditor class PdfAnnotationEditor editor = new PdfAnnotationEditor(); // Bind input PDF file editor.BindPdf(dataDir + "inFile.pdf"); // Create a file stream for output XFDF file to export annotations FileStream fileStream = new FileStream(dataDir + "exportannotations.xfdf", FileMode.Create, FileAccess.Write); // Create an enumeration of all the annotation types which you want to export Enum[] annoType = { AnnotationType.Text }; // Export annotations of specified type(s) to XFDF file editor.ExportAnnotationsXfdf(fileStream, 1, 5, annoType);
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn