How can I redact content in a PDF document?
Estimated Reading Time: 1 MinutesThe recommended approach to redact content, including Text and other elements, is to utilize Redaction annotations, which is a two-step process. Redaction annotations are first placed on a page and then applied, which will cause any content underneath to be removed. The Redaction annotations supported by the SDK work in the same manner as the Acrobat Redact feature. Often, usage of the Redaction annotation is combined with the WordFinder or PDDocTextFinder (regex) to locate the specific words or patterns that you need to protect.
See the AddRedaction and AddRegexRedaction code samples for C++
.NET and Java
- See the Redactions and AddRegexRedaction code samples for .NET
- See the Redactions and AddRegexRedaction code samples for .NET Framework
- See the Redactions and AddRegexRedaction code samples for Java
Text removal
Alternatively, when only processing text, an application can acquire the Page Content, then iterate through the elements checking for PDEText elements, recursing down through Forms and Containers. When taking this approach, it is recommended that the application iterate in reverse order from n-1 to 0.