Redact PDFs using regex
Nutrient Web SDK allows you to search text matching a regular expression and redact it.
You can use instance.createRedactionsBySearch
to do this:
await instance.createRedactionsBySearch("J[a-zA-Z]+t", { searchType: PSPDFKit.SearchType.REGEX });
The code above will search all the four-letter words in the document and add redaction annotations over them. If you’re happy with the added redaction annotations, you can apply them using instance.applyRedactions
. This is an irreversible process.
Keep in mind that each setup uses a different regex syntax:
-
Nutrient Web SDK — JavaScript (see Mozilla’s regular expressions)
-
Nutrient Web SDK with Document Engine — ICU regular expressions, which are derivative of Perl regular expressions