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: NutrientViewer.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(opens in a new tab))
- Nutrient Web SDK with Document Engine — ICU regular expressions(opens in a new tab), which are derivative of Perl regular expressions