Redact PDFs Using RegEx

PSPDFKit for Web allows you to search text matching a regular expression and redact it.

Launch Demo

You can use instance.createRedactionsBySearch to do this:

await instance.createRedactionsBySearch("J[a-zA-Z]+t", {
  searchType: PSPDFKit.SearchType.REGEX
});

The above code will search all the four-letter words in the document and add redaction annotations over them in both Server and Standalone setups. If you’re happy with the added redaction annotations, you can apply them using instance.applyRedactions. This is an irreversible process.

Please keep in mind that each setup uses a different regex syntax: