Removes specific range of pages (slides, worksheets, etc.)
RemovePageRedaction
Apply redaction
Applying redaction to a document is done through Redactor.apply method. As a result, you receive RedactorChangeLog instance, containing a log entry for each redaction applied. The entry contains reference to Redacton instance including its options, status of the operation (see below) and textual descriptions when applicable. If at least one redaction failed, you will see Status == RedactionStatus.Failed:
All operations within redaction process were successfully applied
PartiallyApplied
Redaction was applied only to a part of its matches
1) Trial limitations for replacements were exceeded2) At least one change was rejected by user
Skipped
Redaction was skipped (not applied)
1) Trial limitations for redactions were exceeded2) Redaction cannot be applied to this type of document3) All replacements were rejected by user and no changes were made
Failed
Redaction failed with exception
An exception occurred in process of redaction
For detailed information you have to iterate through redaction log entries in RedactorChangeLog.RedactionLog and check for ErrorMessage property of any items with status other than Applied:
RedactorChangeLogsummary=redactor.apply(...);if(result.getStatus()!=RedactionStatus.Failed){for(RedactorLogEntrylogEntry:result.getRedactionLog()){if(logEntry.getResult().getStatus()!=RedactionStatus.Applied){System.out.println(logEntry.getRedaction().getClass().getName()+" status is "+logEntry.getResult().getStatus()+", details: "+logEntry.getResult().getErrorMessage());}}}
Apply multiple redactions
You can apply as much redactions as you need in a single call to Redactor.Apply() method, since its overload accepts an array of redactions and redaction policy. In this case, redactions will be applied in the same order as they appear in the array. As an alternative to specifying redaction sets in your code, you can create an XML file with redaction policy, as described here.
finalRedactorredactor=newRedactor("sample.docx");try{Redaction[]redactionList=newRedaction[]{newExactPhraseRedaction("John Doe",newReplacementOptions("[Client]")),newRegexRedaction("Redaction",newReplacementOptions("[Product]")),newRegexRedaction("\\d{2}\\s*\\d{2}[^\\d]*\\d{6}",newReplacementOptions(java.awt.Color.BLUE)),newDeleteAnnotationRedaction(),newEraseMetadataRedaction(MetadataFilters.All)};redactor.apply(redactionList);// false, if at least one redaction failed
if(result.getStatus()!=RedactionStatus.Failed){redactor.save();}}finally{redactor.close();}
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.