In some cases, you might need to pre-rasterize the document before opening it and applying redactions.
For instance, you might need to use an ImageAreaRedaction for a whole page of a document with searchable text and images. In order to do that, you will need to pass the Boolean flag to the LoadOptions class constructor.
The following example demonstrates how to pre-rasterize a Microsoft Word document:
constredaction=require('@groupdocs/groupdocs.redaction');constjava=require('java');constColor=java.import('java.awt.Color');constDimension=java.import('java.awt.Dimension');constPoint=java.import('java.awt.Point');constloadOptions=newredaction.LoadOptions(/*preRasterize*/true);constredactor=newredaction.Redactor('sample.docx',loadOptions);try{// Make changes to the file as a rasterized PDF, e.g. uisng ImageAreaRedaction:
constsamplePoint=newPoint(516,311);constsampleSize=newDimension(170,35);constresult=redactor.apply(newredaction.ImageAreaRedaction(samplePoint,newredaction.RegionReplacementOptions(Color.RED,sampleSize)));if(result.getStatus()!==redaction.RedactionStatus.Failed){redactor.save();};}finally{redactor.close();}}
sample.docx is the sample file used in this example. Click here to download it.