PDF 文档注释解决方案

使用免费的跨平台应用程序和API从PDF文档中删除注释

如何使用 Aspose.PDF 库为 PDF 文件添加注释

为了对 PDF 文件添加注释,我们将使用 Aspose.PDF API,这是一款功能丰富、功能强大且易于使用的文档操作 API。打开 NuGet 软件包管理器,搜索 Aspose.PDF 然后安装。您也可以在软件包管理器控制台中使用以下命令。

用于编辑文档中的注释和注释的高编码 API

用于使用 .NET、.NET Core、Java、C++ 和安卓对 PDF 文件进行注释的本机 API。 这些是添加到文件中的其他对象,用于扩展文本的内容,为其他用户进行编辑和注释。还可以使文档中的文本更具可读性,突出显示它,加下划线或添加全新的文本。

<% annotation0.feature-page02.h2 %>

<% annotation0.feature-page02.text01 %>

添加脱字符注释-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"));

<% annotation0.feature-page03.h2 %>

<% annotation0.feature-page03.text01 %>

添加圈子注释-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");

<% annotation0.feature-page04.h2 %>

<% annotation0.feature-page04.text01 %>

添加自由文本注释-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");