PPTX
DOCX
XLSX
PDF
ODP
PDF
PDF 文档编辑解决方案
使用免费的跨平台应用程序和 API 查找和删除 PDF 文档中的内容
如何编辑 PDF 文件
为了编辑 PDF 文件,我们将使用 Aspose.PDF API,这是一款适用于 平台的功能丰富、强大且易于使用的文档处理 API。打开 NuGet 软件包管理器,搜索 Aspose.pdf 然后安装。你也可以使用软件包管理器控制台中的以下命令。
编辑 PDF 文档
<% redaction.feature-section-col1.content-01 %>
1。使用文档实例加载 PDF。 1。使用搜索词作为参数创建 textFragmentAbSorber 对象。 1。设置搜索选项。 1。循环浏览要编辑的每个片段。 1。保存 PDF 文件。
系统要求
只要确保你有以下先决条件即可。
- 微软 Windows 或兼容 .NET Framework、.NET Core 和 PHP、vbScript、Delphi、C++ 通过 COM Interop 的操作系统
- 像微软 Visual Studio 这样的开发环境。
- Aspose.PDF for .NET DLL 在你的项目中引用。
编辑 PDF-C#。
Document doc = new Document(dataDir + "test.pdf");
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(searchTerm);
TextSearchOptions textSearchOptions = new TextSearchOptions(true);
textFragmentAbsorber.TextSearchOptions = textSearchOptions;
doc.Pages.Accept(textFragmentAbsorber);
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
foreach (TextFragment textFragment in textFragmentCollection)
{
Page page = textFragment.Page;
Rectangle annotationRectangle = textFragment.Rectangle;
Annotations.RedactionAnnotation annot = new Annotations.RedactionAnnotation(page, annotationRectangle);
annot.FillColor = Color.Black;
doc.Pages[textFragment.Page.Number].Annotations.Add(annot, true);
annot.Redact();
}
doc.Save(dataDir + "output.pdf");