翻譯|使用教程|編輯:李顯亮|2021-01-07 10:35:19.127|閱讀 423 次
概述:由于PDF文件不容易編輯,因此可使用注釋使用注釋,彈出窗口和各種其他圖形對象來添加有關內容的注釋。在本文中,將學習如何以編程方式使用PDF文檔中的注釋。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
PDF批注是用于標記PDF內容的其他對象。由于PDF文件不容易編輯,因此可使用注釋使用注釋,彈出窗口和各種其他圖形對象來添加有關內容的注釋。
在本文中,將學習如何以編程方式使用PDF文檔中的注釋。特別是,本文將介紹如何使用C#在PDF文件中添加和刪除注釋。
為了在.NET應用程序中使用PDF文檔,Aspose提供了.NET的Aspose.PDF。該API可讓您無縫創建新文件以及處理現有PDF文件。它還允許您在幾行代碼中添加和刪除PDF注釋。
使用C#將注釋添加到PDF
PDF格式支持各種類型的注釋,例如文本,線條,圓形,正方形,修訂等。為了與每個PDF注釋一起使用,Aspose.PDF for .NET提供了單獨的類。例如,LineAnnotation類用于添加行,而HighlightAnnotation類用于添加突出顯示注釋。讓我們看一下在PDF文檔中添加任何類型的注釋的步驟。
使用C#在PDF中添加注釋的步驟
為了演示,下面的代碼示例演示如何使用C#將行注釋添加到PDF。
// Load the PDF file Document document = new Document("Input.pdf"); // Create Line Annotation var lineAnnotation = new LineAnnotation( document.Pages[1], new Rectangle(550, 93, 562, 439), new Point(556, 99), new Point(556, 443)) { Title = "John Smith", Color = Color.Red, Width = 3, StartingStyle = LineEnding.OpenArrow, EndingStyle = LineEnding.OpenArrow, Popup = new PopupAnnotation(document.Pages[1], new Rectangle(842, 124, 1021, 266)) }; // Add annotation to the page document.Pages[1].Annotations.Add(lineAnnotation); // Save PDF document.Save("output.pdf");
在C#中從PDF刪除注釋
可以使用Aspose.PDF for .NET從現有PDF文檔中刪除PDF批注。您可以從PDF刪除全部或特定注釋。以下是刪除PDF注釋的步驟。
下面的代碼示例演示如何使用C#從PDF文件中刪除注釋。
// Open document Document pdfDocument = new Document("DeleteAnnotationsFromPage.pdf"); // Delete particular annotation pdfDocument.Pages[1].Annotations.Delete(); // Or delete particular annotation // pdfDocument.Pages[1].Annotations.Delete(1); // Save updated document pdfDocument.Save("output.pdf");
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn