Developer Tools
|
Office Productivity Applications
|
Platform-Agnostic APIs
|
Home | Online Demos | Downloads | Buy Now | Support | About Us | News | Working Together | Contact Us
In Version 4 of PDFOne .NET, we have introduced text redaction. You can redact text by specifying a region to be redacted. You can also provide a text string whose occurrences in the document can be redacted. The text string can be a literal search text or it can be a regular expression. In this article, we will see examples of both.
The following code snippet shows how to perform simple text redaction using literal search text.
PDFDocument PDFDocument1 = new PDFDocument("your-license-key"); // Load PDF document PDFDocument1.Load("sample_doc1.pdf"); PDFDocument1.RedactText( // redact in page with number 1, // redact text matching "gnostice" "gnostice", // search for literal matches PDFSearchMode.LITERAL, // match all cases and instances PDFSearchOptions.NONE, // stroke redacted regions in red color new Pen(Color.Red), // fill redacted region in lime color new SolidBrush(Color.Lime), // enable stroking of redacted regions true, // enable filling of redacted regions true); PDFDocument1.Save("redacted_doc1.pdf"); // Close the document PDFDocument1.Close();
You can also use regular expressions with the redactText
method.
I have modified the above code snippet so that it will redact all phone numbers, like this:
PDFDocument1.RedactText( // redact in page with number 2 17, // redact phone numbers @"\(\d{3}\)\s\d{3}-\d{4}", // search for regular expression matches PDFSearchMode.REGEX, // match all cases and instances PDFSearchOptions.NONE, // stroke redacted regions in red color new Pen(Color.Red), // fill redacted region in lime color new SolidBrush(Color.Lime), // enable stroking of redacted regions true, // enable filling of redacted regions true);
---o0O0o---
Our .NET Developer Tools | |
---|---|
![]() Gnostice Document Studio .NETMulti-format document-processing component suite for .NET developers. |
![]() PDFOne .NETA .NET PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, and bookmark PDF documents in .NET applications. |
Our Delphi/C++Builder developer tools | |
---|---|
![]() Gnostice Document Studio DelphiMulti-format document-processing component suite for Delphi/C++Builder developers, covering both VCL and FireMonkey platforms. |
![]() eDocEngine VCLA Delphi/C++Builder component suite for creating documents in over 20 formats and also export reports from popular Delphi reporting tools. |
![]() PDFtoolkit VCLA Delphi/C++Builder component suite to edit, enhance, view, print, merge, split, encrypt, annotate, and bookmark PDF documents. |
Our Java developer tools | |
---|---|
![]() Gnostice Document Studio JavaMulti-format document-processing component suite for Java developers. |
![]() PDFOne (for Java)A Java PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, bookmark PDF documents in Java applications. |
Our Platform-Agnostic Cloud and On-Premises APIs | |
---|---|
![]() StarDocsCloud-hosted and On-Premises REST-based document-processing and document-viewing APIs |
Privacy | Legal | Feedback | Newsletter | Blog | Resellers | © 2002-2023 Gnostice Information Technologies Private Limited. All rights reserved. |