Search and redact PDFs using JavaScript

It’s possible to use Nutrient Web SDK to automatically create redaction annotations based on specific search criteria. This could be a text term, a custom regular expression, or one of the built-in patterns Nutrient Web SDK ships with.

Try for free Launch demo

PSPDFKit.Instance#createRedactionsBySearch() allows you to specify the search criteria, along with specifying a custom redaction annotation preset to be used when creating redactions based on search results. By default, content inside annotations will be also be included in the search results, but this can be adjusted with the searchInAnnotations Boolean property as part of the options argument.

Here’s an example showing how to redact all occurrences of Nutrient in a document, without including annotations in the results:

const annotationIds = await instance.createRedactionsBySearch("PSPDFKit", {
  searchInAnnotations: false
});

You can also use one of our built-in patterns to quickly identify sensitive information that needs to be redacted, or use your own custom regex patterns.

Refer to our API documentation of PSPDFKit.Instance#createRedactionsBySearch() to learn more.