PDF 註釋

使用免費的跨平台應用程序和 API 從 PDF 文檔中刪除註釋

如何使用 Aspose.PDF 文件庫註釋 PDF 文件

註釋是 PDF 文件的重要部分。Aspose.PDF 是一個適合開發人員的 .NET PDF 組件,可以滿足您的註釋需求。使用 Aspose.PDF,您可以添加新註釋,編輯現有的註釋,刪除註釋等。為了註釋 PDF 文件,我們將使用 Aspose.PDF API,該 API 是一個功能豐富,功能強大且易於使用的文檔操作 API。打開 NuGet 軟件包管理器,搜索 Aspose.PDF 並安裝。您也可以使用套件管理員主控台中的下列命令。

用於編輯文檔中的註釋和註釋的高程式碼 API

使用 .NET,Java,C++ 和安卓來註釋 PDF 文件的原生 API。 這些是您新增到檔案中的其他物件,以展開文字內容、編輯、為其他使用者註解。也可以使文檔中的文本更易讀,突出顯示,加底線或添加完全新的文本。

通過 C# 將字符註釋添加到 PDF

使用 字符 對 PDF 文件進行註釋 使用 C# 和 Aspose.PDF 用 .NET 程式庫的註釋。

新增字符註解-C#

// Load the PDF file
Document document = new Document(System.IO.Path.Combine(_dataDir, "sample.pdf"));
// This annotation is used to indicate the insertion of text
var caretAnnotation1 = new CaretAnnotation(document.Pages[1],
    new Rectangle(299.988, 713.664, 308.708, 720.769))
{
    Title = "Aspose User",
    Subject = "Inserted text 1",
    Flags = AnnotationFlags.Print,
    Color = Color.Blue
};
document.Pages[1].Annotations.Add(caretAnnotation1);
document.Save(System.IO.Path.Combine(_dataDir, "sample_caret.pdf"));

通過 Java 將圓形註釋添加到 PDF

使用 圓圈 對 PDF 文檔進行註釋 使用 Java 與 Aspose.PDF 用於 Java 程式庫進行註釋。

新增圓圈註釋-Java

// Load the PDF file
Document document = new com.aspose.pdf.Document(_dataDir + "appartments.pdf");
Page page = document.getPages().get_Item(1);

// Create Polygon Annotation
CircleAnnotation circleAnnotation = new CircleAnnotation(page, new Rectangle(270, 160, 483, 383));
circleAnnotation.setTitle("John Smith");
circleAnnotation.setColor(Color.getRed());
circleAnnotation.setInteriorColor(Color.getMistyRose());
circleAnnotation.setOpacity(0.5);
circleAnnotation.setPopup(new PopupAnnotation(page, new Rectangle(842, 316, 1021, 459)));

// Add annotation to the page
page.getAnnotations().add(circleAnnotation);
document.save(_dataDir + "appartments_mod.pdf");

通過 C++ 將免費文本註釋添加到 PDF

使用 免費文本使用 C++ 和 Aspose.PDF 用 C++ 庫進行註釋為 PDF 文檔進行註釋。

添加免費文本註釋-C++

String _dataDir("C:\\Samples\\");

// Load the PDF file
auto document = MakeObject<Document>(_dataDir + u"sample.pdf");
auto page = document->get_Pages()->idx_get(1);

auto defaultAppearance = MakeObject<DefaultAppearance>();
defaultAppearance->set_FontName(u"Helvetica");
defaultAppearance->set_FontSize(12);
defaultAppearance->set_TextColor(System::Drawing::Color::get_Blue());

auto freeTextAnnotation = MakeObject<FreeTextAnnotation>(page, new Rectangle(300.0, 770.0, 400.0, 790.0), defaultAppearance);

freeTextAnnotation->set_RichText(u"Free Text Demo");
page->get_Annotations()->Add(freeTextAnnotation);
document->Save(_dataDir + u"sample_freetext.pdf");