PdfRedactor
Static one-call API. File, stream, byte-array, or attachment input. Sync and async.
A black box over a name still ships it. PdfRedactor
deletes the text, pixels and vectors underneath, then re-reads the output to prove it.
PdfRedactorStatic one-call API. File, stream, byte-array, or attachment input. Sync and async.
Text outside a mark keeps its exact position. Only the glyphs under the region are deleted, then the object is rebuilt.
The underlying data is erased. Removed content cannot be recovered by text extraction, raw stream inspection, or rendering.
One pass removes text, pixels, vectors, and annotations under each region, and descends into reused resources. Shared forms and images are cloned before editing, so only the targeted instance changes.
Text
Glyphs under the region are deleted from the content stream and the text object is rebuilt with its remaining glyphs in place. Neighbouring text never shifts.
Images
Image pixels intersecting a region are scrubbed and the image is re-encoded. An image that cannot be decoded is removed entirely, so redacted pixel data never survives.
Vectors
Vector path content intersecting a region is removed or trimmed, so charts, rules, and fills under the mark disappear with the text.
Annotations
Annotations whose rectangle intersects a region are deleted. Their markup contents, link targets, and form field values often duplicate the redacted content.
Forms
Redaction descends into Form XObjects. The affected instance is cloned before editing, so the same form referenced from other pages keeps its original content.
Marking
Mark by SearchTerms (plain or regular expressions), explicit PdfRedactionArea regions, or the file's /Redact annotations. Combine all three.
Primitives
A redaction area takes any IBounds: a Rectangle, a layout TextElement, or a search match's bounds. Fill colour is a Color32, alpha included.
Encryption
Pass the password and the engine opens protected sources. The redacted output is always written unencrypted.
Report
Every redaction returns a report: pages processed, search matches, glyphs and text objects removed, images and paths edited, forms cloned, annotations deleted.
Every occurrence of each term is found and permanently removed, and a report says what changed.
using LMKit.Document.Pdf; var request = new PdfRedactionRequest(); request.SearchTerms.Add("John Doe"); request.SearchTerms.Add("4111 1111 1111 1111"); var report = PdfRedactor.RedactToFile("contract.pdf", "contract_redacted.pdf", request); Console.WriteLine($"Matches: {report.SearchMatches}, glyphs removed: {report.RemovedGlyphs}");
Mark a fixed region in top-left origin page points. An area is any IBounds, so a Rectangle drops straight in.
using LMKit.Document.Pdf; using LMKit.Graphics.Geometry; using LMKit.Graphics.Primitives; var request = new PdfRedactionRequest(); request.Areas.Add(new PdfRedactionArea(pageIndex: 0, Rectangle.FromSize(left: 72, top: 90, width: 220, height: 30))); var options = new PdfRedactionOptions { FillColor = Color32.FromRgb(0x333333), // fill box colour; alpha honored }; var report = PdfRedactor.RedactToFile("report.pdf", "report_redacted.pdf", request, options);
Bytes in, redacted bytes plus report out. Suited to web services and pipelines where documents never touch disk.
using LMKit.Document.Pdf; // Bytes in, redacted bytes plus report out. No temp files. byte[] source = await httpClient.GetByteArrayAsync(documentUrl); var request = new PdfRedactionRequest(); request.SearchTerms.Add("CONFIDENTIAL"); PdfRedactionResult result = await PdfRedactor.RedactToBytesAsync(source, request); await blobStore.UploadAsync(result.Data); Console.WriteLine($"Content removed: {result.Report.ContentRemoved}");
Match by regular expression, label each box, and strip the hidden data redaction alone cannot reach.
using LMKit.Document.Pdf; using LMKit.Graphics.Geometry; var request = new PdfRedactionRequest { UseRegularExpressions = true }; request.SearchTerms.Add(@"\bINV-\d{6}\b"); // every invoice number request.Areas.Add(new PdfRedactionArea(pageIndex: 0, Rectangle.FromSize(left: 72, top: 90, width: 220, height: 30), label: "Client name")); // drawn as outlines, adds no text var options = new PdfRedactionOptions { // Metadata, attachments, JavaScript, bookmarks, XFA, thumbnails... Sanitize = PdfSanitizeTargets.All, // VerifyRedaction is on by default: residual text throws, nothing is written. }; var report = PdfRedactor.RedactToFile("statement.pdf", "statement_redacted.pdf", request, options); Console.WriteLine($"Verified: {report.Verified}, labels drawn: {report.LabelsDrawn}");
Nothing under a mark survives extraction, stream inspection or rendering, and everything outside it stays exactly where it was.
PdfRedactionVerificationException and nothing is writtenSanitize strips metadata, attachments, JavaScript, bookmarks, PieceInfo, XFA, thumbnails and structure-tree textAllowSignatureInvalidation consents to breaking its signaturesMerge, split, render, search-highlight, unlock, and inspect PDFs with the same library.
Locate names, IDs, and card numbers first with document search, then feed the matches straight into redaction areas.
PdfAConverter turns existing PDFs into archival PDF/A-1b / 2b / 3b: fonts embedded, colours calibrated, prohibited constructs removed.
Let an on-device model find the PII for you, review it with a human in the loop, then remove it with this engine. Detection plus removal in one workflow.
Working console demos on GitHub, step-by-step how-to guides on the docs site, and the API reference for the classes used on this page.