Redaction options to use when this document is viewed or converted.
public DocumentRedactionOptions RedactionOptions {get; set;} Public Property RedactionOptions() As DocumentRedactionOptionsGetSet
public:property DocumentRedactionOptions^ RedactionOptions{DocumentRedactionOptions^ get()void set(DocumentRedactionOptions^ value)}
The redaction options to use when this document is viewed or converted. The default value is null.
The default value of null instructs the DocumentViewer and DocumentConverter to not perform any special processing for the annotation objects in the pages of this LEADDocument during viewing or converting.
To apply the annotations, set a new instance of DocumentRedactionOptions in RedactionOptions and modify its options for the desired operations.
For more information, refer to Document View and Convert Redaction.
This example will load a PDF document, then dynamically apply redactions to any word containing "leadtools" found, and save the results back into an external PDF.
using Leadtools;using Leadtools.Codecs;using Leadtools.Document.Writer;using Leadtools.Document;using Leadtools.Caching;using Leadtools.Annotations.Engine;using Leadtools.Ocr;using Leadtools.Barcode;using Leadtools.Document.Converter;public void DocumentRedactionExample(){var cache = new FileCache();cache.CacheDirectory = @"c:\cache-dir";using (var documentConverter = new DocumentConverter()){// Load a PDF filedvar loadDocumentOptions = new LoadDocumentOptions();loadDocumentOptions.Cache = cache;using (LEADDocument document = DocumentFactory.LoadFromUri(new Uri("http://demo.leadtools.com/images/pdf/leadtools.pdf"), loadDocumentOptions)){// Convert to PDF using default optionsstring outFileName = Path.Combine(LEAD_VARS.ImagesDir, "no-redaction.pdf");DocumentRedactConvert(documentConverter, document, DocumentFormat.Pdf, outFileName);// Open the converted document no-redaction.pdf, notice that it resembles the original document// We will use DocumentPageText to dynamically find the location of all words containing "leadtools"document.IsReadOnly = false;const string toRedact = "leadtools";DocumentPage documentPage = document.Pages[0];DocumentPageText pageText = documentPage.GetText();pageText.BuildWords();AnnContainer container = documentPage.GetAnnotations(true);foreach (DocumentWord word in pageText.Words){// Find if the word is oursif (word.Value.Contains(toRedact)){// Yes, redact itvar annRedactionObject = new AnnRedactionObject();annRedactionObject.Rect = word.Bounds;container.Children.Add(annRedactionObject);}}// Set the container into the pagedocumentPage.SetAnnotations(container);// Set the redaction optionsdocument.Annotations.RedactionOptions = new DocumentRedactionOptions();document.Annotations.RedactionOptions.ViewOptions.Mode = DocumentRedactionMode.Apply;document.Annotations.RedactionOptions.ViewOptions.ReplaceCharacter = '*';document.Annotations.RedactionOptions.ConvertOptions.Mode = DocumentRedactionMode.Apply;document.Annotations.RedactionOptions.ConvertOptions.ReplaceCharacter = '*';document.IsReadOnly = true;// Convert again, the result should have all instance of "leadtools" in the first page and replaced with *outFileName = Path.Combine(LEAD_VARS.ImagesDir, "redacted.pdf");DocumentRedactConvert(documentConverter, document, DocumentFormat.Pdf, outFileName);}}}private static void DocumentRedactConvert(DocumentConverter documentConverter, LEADDocument document, DocumentFormat documentFormat, string outFileName){var jobData = new DocumentConverterJobData();jobData.Document = document;jobData.DocumentFormat = documentFormat;jobData.RasterImageFormat = RasterImageFormat.Unknown;jobData.OutputDocumentFileName = outFileName;DocumentConverterJob job = documentConverter.Jobs.CreateJob(jobData);documentConverter.Jobs.RunJob(job);}static class LEAD_VARS{public const string ImagesDir = @"C:\LEADTOOLS21\Resources\Images";}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.Document.WriterImports Leadtools.SvgImports Leadtools.DocumentImports Leadtools.CachingImports Leadtools.Annotations.EngineImports Leadtools.BarcodeImports Leadtools.OcrImports LeadtoolsDocumentExamples.LeadtoolsExamples.CommonImports Leadtools.Document.ConverterPublic Shared Sub DocumentRedactionExample()Using documentConverter As New DocumentConverter()' Load a PDF filedDim loadDocumentOptions As New LoadDocumentOptions()Using document As LEADDocument = DocumentFactory.LoadFromUri(New Uri("http://demo.leadtools.com/images/pdf/leadtools.pdf"), loadDocumentOptions)' Convert to PDF using default optionsDim outFileName As String = Path.Combine(ImagesPath.Path, "no-redaction.pdf")DocumentRedactConvert(documentConverter, document, DocumentFormat.Pdf, outFileName)' Open the converted document no-redaction.pdf, notice that it resembles the original document' We will use DocumentPageText to dynamically find the location of all words containing "leadtools"document.IsReadOnly = FalseConst toRedact As String = "leadtools"Dim documentPage As DocumentPage = document.Pages(0)Dim pageText As DocumentPageText = documentPage.GetText()pageText.BuildWords()Dim container As AnnContainer = documentPage.GetAnnotations(True)For Each word As DocumentWord In pageText.Words' Find if the word Is oursIf word.Value.Contains(toRedact) Then' Yes, redact itDim annRedactionObject As New AnnRedactionObject()annRedactionObject.Rect = word.Boundscontainer.Children.Add(annRedactionObject)End IfNext' Set the container into the pagedocumentPage.SetAnnotations(container)' Set the redaction optionsdocument.Annotations.RedactionOptions = New DocumentRedactionOptions()document.Annotations.RedactionOptions.ViewOptions.Mode = DocumentRedactionMode.Applydocument.Annotations.RedactionOptions.ViewOptions.ReplaceCharacter = "*"cdocument.Annotations.RedactionOptions.ConvertOptions.Mode = DocumentRedactionMode.Applydocument.Annotations.RedactionOptions.ConvertOptions.ReplaceCharacter = "*"cdocument.IsReadOnly = True' Convert again, the result should have all instance of "leadtools" in the first page And replaced with *outFileName = Path.Combine(ImagesPath.Path, "redacted.pdf")DocumentRedactConvert(documentConverter, document, DocumentFormat.Pdf, outFileName)End UsingEnd UsingEnd SubPrivate Shared Sub DocumentRedactConvert(documentConverter As DocumentConverter, document As LEADDocument, documentFormat As DocumentFormat, outFileName As String)Dim jobData As New DocumentConverterJobData()jobData.Document = documentjobData.DocumentFormat = documentFormatjobData.RasterImageFormat = RasterImageFormat.UnknownjobData.OutputDocumentFileName = outFileNameDim job As DocumentConverterJob = documentConverter.Jobs.CreateJob(jobData)documentConverter.Jobs.RunJob(job)End Sub
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
