How Redaction Works in the Apryse Server SDK
To redact a PDF in C# with the Apryse Server SDK, initialize PDFNet, identify the content to remove by creating redact annotations through text search or text extraction, then call the apply step to destroy the text, image and vector content inside those regions. The marking step is reversible; applying the redaction is not.
Redaction in C# with the Apryse Server SDK is a two-step sequence, not one call that finds and deletes content in a single pass. Step one is content identification. Redact annotations mark the text, images or regions to remove, either interactively or in code through text search or text extraction. Until step two runs, you can still view, move and redefine each mark.
Step two is content removal. The method Redactor.Redact applies the marked regions and destroys the content inside them. If part of an image, text or vector graphic falls inside a region, the SDK removes that part of the image or path data. It does not hide it behind a clipping path or an image mask.
The split exists so a reviewer approves before anything is destroyed. Your application owns that approval step. The SDK owns the destruction, and applying a redaction is permanent. Once you save the output, the removed content cannot be restored from it.
C# is the language you write. .NET is the framework your service runs on. A search to redact PDF using .NET and a search for redaction in C# reach the same API, so this page serves both and covers VB.NET in its own section.
This page covers one path through the PDF redaction library that Apryse ships. The PDF redaction SDK developer guide routes you by language and framework. If your service runs another language, see how to redact PDFs in Python or server-side redaction in Java.
Redaction Support and Licensing Matrix
Setting Up: Initialization and Licensing
Install the Apryse Server SDK for your runtime, then call PDFNet.Initialize with your license key before any other SDK call. Call PDFNet.Terminate when the process ends. In a service, initialize once at startup, not per request.
The SDK is self-hosted. It processes documents on your servers, so no document content leaves your environment. That lets you run redaction on your own infrastructure for statements, claim files and case documents in financial services, healthcare, government and legal work.
Redaction is an add-on license, and it ships in the base binary so there's no separate module to download. Your production license key needs the Redaction Package but trial keys include all packages.
License keys are confidential so don't commit them to public repositories. Use environment variables or a secrets manager to inject your key at runtime. The code on this page reads the key from APRYSE_LICENSE_KEY.
Get your free trial key at dev.apryse.com before running the code.
Identifying Content to Redact
Content identification produces the list of regions that Redactor. Redact applies.
You have two routes:
- Interactively, a reviewer marks the content to remove.
- Programmatically, your service finds it with pdftron.PDF.TextSearch or pdftron.PDF.TextExtractor.
The PDFRedact sample builds each region as a Redactor.Redaction object. Each object holds a page number, a rectangle, a negative flag and overlay text. Your code decides which regions to create, and the SDK removes only what you mark.
Pattern Matching for PII
Pattern matching finds content you cannot locate by coordinates. The SDK searches by text string, regular expression or pattern. Social Security numbers, credit card numbers and other PII are the documented examples. Search also supports ambient string and wildcard matching.
Run your search over the document, then record every match as a region for step two. You write the pattern, and the SDK matches it. A pattern that matches too much destroys content you meant to keep, and the removal is permanent. Test every pattern against representative documents before you apply it.
Applying the Redaction
Applying the redaction is one call. Redactor.Redact takes the document, the list of regions, an appearance object and two Boolean flags, then destroys the content inside every region. Redactor.Appearance controls the overlay style, including color, text, font, border and transparency. The overlay is cosmetic. The removal happens underneath it.
The example below marks one region on page 1 of a statement, applies it and saves the result to a separate file. It follows the initialize, operate, terminate pattern the Server SDK requires and targets C# on .NET 8 and 9.
ProcessStatement initializes PDFNet, opens the statement, calls InitSecurityHandler as the PDFRedact sample does, applies the redactions and saves. Saving to redactedPath leaves the original untouched until verification passes. Replace the rectangle with the regions from your own identification step.
Verifying the Content Was Removed
A redaction can succeed and still be wrong. A rectangle placed a line too low removes the wrong content, leaves the sensitive text in place and still saves a valid PDF. Verify the saved output, not the marks.
- Extract the text of every redacted page in the saved file with pdftron.PDF.TextExtractor and confirm the removed strings are absent.
- Run the same patterns through pdftron.PDF.TextSearch against the saved file and expect zero matches.
- Open the saved file in a viewer. Confirm each overlay sits over the intended region and the surrounding content is intact.
Extraction and search checks tell true redaction versus visual masking apart. Masked text still comes back from extraction. Removed text does not.
Verification covers visible content only. Check hidden data separately, as the last section explains.
Redacting in VB.NET on the Same Framework
VB.NET is a separate language that runs on the same framework as C#. It calls the same Redactor classes in the same sequence. The SDK ships a VB version of the PDFRedact sample, and .NET Framework projects follow the get-started guide for C# and VB.
The example mirrors the C# version: initialize, mark a region, apply, save, terminate.
For a longer write-up on the framework, see PDF redaction in .NET.
What the Server SDK Does Not Do
Redaction removes visible content: text, images and vector regions. It does not remove hidden data. Metadata, XFA, XMP, embedded scripts, form data and hidden layers belong to PDF sanitization, a separate Server SDK capability included in the base package.
A document that needs both gets redaction applied first and then sanitization run. The page on redaction versus sanitization covers where the boundary sits.
The Server SDK provides no work queue, job scheduler or batch orchestration. If you are redacting documents in bulk, your code owns the loop, the parallelism and the retry behavior.
The SDK holds no state between operations, so you choose sequential, threaded, multi-process or scaled-out processing. Initialize once per process. Give each thread its own document or use the SDK locking APIs when threads share one.
The SDK also does not decide what is sensitive or who approves a redaction. Your application owns classification, review and approval.
Frequently Asked Questions
Initialize PDFNet, create redact annotations to mark the regions or text to remove, then call the apply step. The apply step destroys the text, image and vector content inside the marked regions rather than hiding it, and the operation is irreversible.
Yes. Content can be identified programmatically through text search or text extraction, and pattern matching supports ambient string, wildcards and regular expressions. SSNs, credit card numbers and other PII are the documented pattern examples.
No. Redaction removes visible page content inside the marked regions. Metadata, XFA, XMP, embedded scripts, form data and hidden layers are removed by Sanitization, which is a separate Server SDK capability included in the base package.
No, and deliberately so. C# is the language and .NET is the framework it runs on, so a separate .NET page would target the same developer and the same API surface. This page covers .NET searches too. VB.NET has its own section because it is a different language on the same framework.
Redaction does not remove those. Metadata, XFA, XMP, embedded scripts, form data and hidden layers are removed by Sanitization, a separate Server SDK capability in the base package. A document that needs both gets redaction applied and then sanitization run.
An add-on license. The Redaction Package must be on your production license key. Redaction ships in the base binary, so there is no separate module to download, and trial keys include all packages.
Loop over the documents and apply the same detection and apply steps to each. The Server SDK provides no work queue, job scheduler or batch orchestration, so your code owns the loop, the parallelism and the retry behavior.




