Options to use when applying the redactions during viewing.
public ViewRedactionOptions ViewOptions { get; set; }
public:
property ViewRedactionOptions^ ViewOptions
{
ViewRedactionOptions^ get()
void set(ViewRedactionOptions^ value)
}
ViewOptions # get and set (DocumentRedactionOptions)
The options to use when applying the redactions during viewing. The default value is a new instance of ViewRedactionOptions.
For more information, refer to Document View and Convert Redaction.
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()
{
// AnnotationsRedactionOptions redactionOptions = new AnnotationsRedactionOptions();
var cache = new FileCache();
cache.CacheDirectory = @"c:\cache-dir";
using (var documentConverter = new DocumentConverter())
{
// Load a PDF filed
var 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 options
string 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 ours
if (word.Value.Contains(toRedact))
{
// Yes, redact it
var annRedactionObject = new AnnRedactionObject();
annRedactionObject.Rect = word.Bounds;
container.Children.Add(annRedactionObject);
}
}
// Set the container into the page
documentPage.SetAnnotations(container);
// Set the redaction options
// AnnotationRedactionOptions & ConvertRedactionOptions reference
document.Annotations.RedactionOptions = new DocumentRedactionOptions();
// ViewRedactionOptions & AnnotationsRedactionOptions reference
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:\LEADTOOLS23\Resources\Images";
}
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.regex.Pattern;
import org.junit.*;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
import static org.junit.Assert.*;
import leadtools.*;
import leadtools.annotations.engine.*;
import leadtools.barcode.*;
import leadtools.caching.*;
import leadtools.codecs.*;
import leadtools.document.*;
import leadtools.document.DocumentMimeTypes.UserGetDocumentStatusHandler;
import leadtools.document.converter.*;
import leadtools.document.writer.*;
import leadtools.ocr.*;
public void documentRedactionOptionsExample() throws URISyntaxException {
final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images";
// AnnotationsRedactionOptions redactionOptions = new
// AnnotationsRedactionOptions();
FileCache cache = new FileCache();
cache.setCacheDirectory("c:\\cache-dir");
DocumentConverter documentConverter = new DocumentConverter();
// Load a PDF filed
LoadDocumentOptions loadDocumentOptions = new LoadDocumentOptions();
loadDocumentOptions.setCache(cache);
LEADDocument document = DocumentFactory.loadFromUri(new URI("http://demo.leadtools.com/images/pdf/leadtools.pdf"),
loadDocumentOptions);
// Convert to PDF using default options
String outFileName = combine(LEAD_VARS_IMAGES_DIR, "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.setReadOnly(false);
final String toRedact = "leadtools";
DocumentPage documentPage = document.getPages().get(0);
DocumentPageText pageText = documentPage.getText();
pageText.buildWords();
AnnContainer container = documentPage.getAnnotations(true);
for (DocumentWord word : pageText.getWords()) {
// Find if the word is ours
if (word.getValue().contains(toRedact)) {
// Yes, redact it
AnnRedactionObject annRedactionObject = new AnnRedactionObject();
annRedactionObject.setRect(word.getBounds());
container.getChildren().add(annRedactionObject);
}
}
// Set the container into the page
documentPage.setAnnotations(container);
// Set the redaction options
// AnnotationRedactionOptions & ConvertRedactionOptions reference
document.getAnnotations().setRedactionOptions(new DocumentRedactionOptions());
// ViewRedactionOptions & AnnotationsRedactionOptions reference
document.getAnnotations().getRedactionOptions().getViewOptions().setMode(DocumentRedactionMode.APPLY);
document.getAnnotations().getRedactionOptions().getViewOptions().setReplaceCharacter('*');
document.getAnnotations().getRedactionOptions().getConvertOptions().setMode(DocumentRedactionMode.APPLY);
document.getAnnotations().getRedactionOptions().getConvertOptions().setReplaceCharacter('*');
document.setReadOnly(true);
// Convert again, the result should have all instance of "leadtools" in the
// first page and replaced with *
outFileName = combine(LEAD_VARS_IMAGES_DIR, "redacted.pdf");
documentRedactConvert(documentConverter, document, DocumentFormat.PDF, outFileName);
}
private static void documentRedactConvert(DocumentConverter documentConverter, LEADDocument document,
DocumentFormat documentFormat, String outFileName) {
DocumentConverterJobData jobData = new DocumentConverterJobData();
jobData.setDocument(document);
jobData.setDocumentFormat(documentFormat);
jobData.setRasterImageFormat(RasterImageFormat.UNKNOWN);
jobData.setOutputDocumentFileName(outFileName);
DocumentConverterJob job = documentConverter.getJobs().createJob(jobData);
documentConverter.getJobs().runJob(job);
}
Document View and Convert Redaction
DocumentRedactionOptions Class
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
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.