如何使用正则表达式和 Java 从 RTF 文件中删除文本

GroupDocs.Redaction 的 Java API 允许使用正则表达式编辑、隐藏或删除文字处理文档、工作表、演示文稿、PDF 和图像中的敏感文本。


下载免费试用版

什么是文本清理?

文本编辑或清理是从数字文档中删除机密或不需要的文本或信息,同时保留包含该文本的文档或段落的其余部分完好无损的过程。密文可帮助用户和组织通过隐藏或永久删除敏感信息来保护其敏感信息。使用 GroupDocs.Redaction Java API,用户现在可以编辑、隐藏或删除文字处理文档、工作表、演示文稿、PDF 和光栅图像文件中的敏感文本。 API 提供了多种选项和方法来编辑文档中的私人信息。它支持使用正则表达式进行搜索和编辑、使用文本(豁免代码)或图形(彩色矩形)编辑等等。那么为什么不尝试一下,通过下载 API 来自动化文档编辑过程并探索其基本和高级功能。

使用 Java 中的正则表达式编辑 RTF

GroupDocs.Redaction 允许轻松编辑文档中的敏感或私人数据。最流行的编辑案例是从文档中删除文本。

以下代码可用于使用正则表达式将文本编辑应用于文档的特定部分。它允许用户替换所有数字,将模式“AA BB CCCCCC”与蓝色矩形匹配,

从 RTF 中删除敏感数据

  • 创建 Redactor 类的实例并上传 RTF 文件
  • 创建 RegexRedaction 类的实例
  • 使用 RegexRedaction 类的对象调用 redactor.apply 方法
  • 调用 redactor.save 方法保存更改


系统要求

GroupDocs.Redaction for Java 所有主要平台和操作系统均支持 API。有关完整的系统要求指南,请访问系统要求 在执行下面的代码之前,请确保您的系统上安装了以下先决条件:

  • 操作系统:Microsoft Windows、Linux、Mac操作系统
  • 开发环境:NetBeans、Intellij IDEA、Eclipse等
  • Java 运行时环境:J2SE 6.0 及更高版本
  • Maven 获取最新版本的 GroupDocs.Redaction for Java

为什么使用GroupDocs.Redaction

  • 允许用户添加自定义文档格式和密文类型
  • 无需额外软件即可删除敏感信息
  • 能够将页面范围渲染文档设置为 PDF
  • 编辑不同类型元数据的简单方法:作者姓名、版本、标题、主题、描述等等
  • 文档信息提取 - 文件类型、页数等。


What is RTF File Format?

Introduced and documented by Microsoft, the Rich Text Format (RTF) represents a method of encoding formatted text and graphics for use within applications. The format facilitates cross-platform document exchange with other Microsoft Products, thus serving the purpose of interoperability. This capability makes it a standard of data transfer between word processing software and, hence, contents can be transferred from one operating system to another without losing document formatting. The file format specifications are available by Microsoft for public download and can be referred to from developer’s perspective.

Read More

受欢迎的 编辑 选择

纂 CSV 文件

(Comma Seperated Values)

纂 DOC 文件

(Microsoft Word Binary Format)

纂 DOCM 文件

(Microsoft Word 2007 Marco File)

纂 DOCX 文件

(Office 2007+ Word Document)

纂 DOT 文件

(Microsoft Word Template Files)

纂 DOTM 文件

(Microsoft Word 2007+ Template File)

纂 DOTX 文件

(Microsoft Word Template File )

纂 PDF 文件

(Portable Document Format)

纂 POT 文件

(Microsoft PowerPoint Template Files)

纂 POTM 文件

(Microsoft PowerPoint Template File)

纂 PPS 文件

(PowerPoint Slide Show)

纂 PPSM 文件

(Macro-enabled Slide Show)

纂 PPSX 文件

(PowerPoint Slide Show)

纂 PPT 文件

(Microsoft PowerPoint 97-2003)

纂 PPTM 文件

(Macro-enabled Presentation File)

纂 PPTX 文件

(Open XML presentation Format)

纂 XLS 文件

(Microsoft Excel Spreadsheet (Legacy))

纂 XLSM 文件

(Macro-enabled Spreadsheet)

纂 XLSX 文件

(Open XML Workbook)

纂 XLT 文件

(Excel 97 - 2003 Template)

纂 XLTM 文件

(Excel Macro-Enabled Template)

纂 XLTX 文件

(Excel Template)

Back to top
 中国人