Search and Redact PDFs in Windows

It’s possible to use PSPDFKit for Windows to automatically create redaction annotations based on specific search criteria. These could be text terms, custom regular expressions, or any of the built-in patterns PSPDFKit for Windows ships with.

Pdf.Document.CreateRedactionsBySearchAsync() allows you to specify the search criteria, along with specifying a custom redaction annotation to be used as a preset when creating redactions based on search results. By default, content inside annotations will also be included in the search results, but this can be adjusted with the SearchInAnnotations Boolean property inside the RedactionSearchOptions class.

Here’s an example showing how to redact all occurrences of PSPDFKit on a document, without including annotations:

var annotationIds = await PDFView.Document.CreateRedactionsBySearchAsync("PSPDFKit", SearchType.Text, new RedactionSearchOptions());

You can also use one of our preset patterns to quickly identify sensitive information that needs to be redacted. Here’s an example of how to create redactions for every social security number found:

var annotationIds = await PDFView.Document.CreateRedactionsBySearchAsync(SearchPattern.SocialSecurityNumber, new RedactionSearchOptions());

The full list of available patterns can be found in our documentation. For more information, please check our API documentation of Pdf.Document.CreateRedactionsBySearchAsync() and our Catalog example.