The following example demonstrates applying a list of redactions to the document.
using(Redactorredactor=newRedactor(@"D:\\test.docx")){varredactionList=newRedaction[]{newExactPhraseRedaction(LookupStrings.ClientName,newReplacementOptions("[client]")),newExactPhraseRedaction(LookupStrings.ClientAddress,newReplacementOptions(System.Drawing.Color.Red)),newRegexRedaction(LookupStrings.SSNRegexPattern,newReplacementOptions("[ssn]")),newRegexRedaction(LookupStrings.BankCardRegexPattern,newReplacementOptions(System.Drawing.Color.Blue)),// ... other redactionsnewDeleteAnnotationRedaction("(?im:(use|show|describe))"),newEraseMetadataRedaction(MetadataFilter.Author),newMetadataSearchRedaction(LookupStrings.CompanyName,"--company--")};RedactorChangeLogresult=redactor.Apply(redactionList);// false, if at least one redaction failedif(result.Status!=RedactionStatus.Failed){redactor.Save();};}
The following example demonstrates how to apply a redaction policy to all files within a given inbound folder, and save to one of outbound folders - for successfully updated files and for failed ones.
The following example demonstrates how to open a password-protected documents using LoadOptions.
LoadOptionsloadOptions=newLoadOptions("mypassword");using(Redactorredactor=newRedactor(@"C:\sample.pdf",loadOptions)){// Here we can use document instance to perform redactions}
The following example demonstrates how to save a document using SaveOptions.
using(Redactorredactor=newRedactor(@"C:\sample.pdf")){// Document redaction goes here// ...// Save the document with default options (convert pages into images, save as PDF)redactor.Save();// Save the document in original format overwriting original fileredactor.Save(newSaveOptions(){AddSuffix=false,RasterizeToPDF=false});// Save the document to "*_Redacted.*" file in original formatredactor.Save(newSaveOptions(){AddSuffix=true,RasterizeToPDF=false});// Save the document to "*_AnyText.*" (e.g. timestamp instead of "AnyText") in its file name without rasterizationredactor.Save(newSaveOptions(false,"AnyText"));}