PdfRedactor
Static one-call API. File, stream, byte-array, or attachment input. Sync and async.
A black rectangle over a name still ships the name underneath. Real
redaction deletes the data. LM-Kit ships PdfRedactor:
one call that removes text glyphs from content streams, scrubs and
re-encodes image pixels, trims vector graphics, deletes intersecting
annotations, and processes content nested inside Form XObjects. What
survives keeps its exact position. Fully on-device.
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 (every occurrence redacted), explicit PdfRedactionArea regions, or the file's pre-existing /Redact annotations. Combine all three in one request.
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}");
Redacted content is removed from the content streams, the image data, and the annotation objects, then the affected pages are regenerated. The result carries no recoverable trace of the removed content through text extraction, raw stream inspection, or rendering, while every glyph, image, and path outside the marks stays exactly where it was. The engine is covered by a regression suite that reopens each redacted output and fails if a secret survives or if surrounding content was damaged.
Merge, 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.