In order to use the advanced rasterization options you have to pass one of the options to Save method. In this case the document will be rasterized to PDF, but the scan-like effects will be applied to its pages.
finalRedactorredactor=newRedactor("Sample.docx");try{// Save the document with advanced options (convert pages into images, and save PDF with scan-like pages)
SaveOptionsso=newSaveOptions();so.setRedactedFileSuffix("_scan");so.getRasterization().setEnabled(true);so.getRasterization().addAdvancedOption(AdvancedRasterizationOptions.Border);so.getRasterization().addAdvancedOption(AdvancedRasterizationOptions.Noise);so.getRasterization().addAdvancedOption(AdvancedRasterizationOptions.Grayscale);so.getRasterization().addAdvancedOption(AdvancedRasterizationOptions.Tilt);redactor.save(so);}finally{redactor.close();}
Use border rasterization option
You can set the custom border width by providing the “border” dictionary item with an integer value.
The following example demonstrates how to apply the border advanced rasterization option with custom settings.
finalRedactorredactor=newRedactor("Sample.docx");try{// Save the document with a custom border
SaveOptionsso=newSaveOptions();so.setRedactedFileSuffix("_scan");so.getRasterization().setEnabled(true);so.getRasterization().addAdvancedOption(AdvancedRasterizationOptions.Border,newHashMap<String,String>(){{put("border","10");}});redactor.save(so);}finally{redactor.close();}
Use grayscale rasterization option
The following example demonstrates how to apply the grayscale advanced rasterization option.
finalRedactorredactor=newRedactor("Sample.docx");try{// Save the document converting it to a grayscale
SaveOptionsso=newSaveOptions();so.setRedactedFileSuffix("_scan");so.getRasterization().setEnabled(true);so.getRasterization().addAdvancedOption(AdvancedRasterizationOptions.Grayscale);redactor.save(so);}finally{redactor.close();}
Use noise rasterization option
You can set up the custom noise effects by providing the “maxSpots” and “spotMaxSize” dictionary items having integer values. The “maxSpots” defines the maximal number of spots, which is random, and “spotMaxSize” defines the largest allowed spot size.
The following example demonstrates how to apply the noise advanced rasterization option with custom settings.
finalRedactorredactor=newRedactor("Sample.docx");try{// Save the document with the custom number and size of noise effects
SaveOptionsso=newSaveOptions();so.setRedactedFileSuffix("_scan");so.getRasterization().setEnabled(true);so.getRasterization().addAdvancedOption(AdvancedRasterizationOptions.Noise,newHashMap<String,String>(){{put("maxSpots","150");put("spotMaxSize","15");}});redactor.save(so);}finally{redactor.close();}
Use tilt rasterization option
You can set up the custom tilt effects by providing the “minAngle” and “randomAngleMax” dictionary items having integer values. The “minAngle” defines the minimal rotation angle and “randomAngleMax” is a maximal rotation angle, randomly added to “minAngle”.
The following example demonstrates how to apply the tilt advanced rasterization option with custom settings.
finalRedactorredactor=newRedactor("Sample.docx");try{// Save the document with the custom tilt effect
SaveOptionsso=newSaveOptions();so.setRedactedFileSuffix("_scan");so.getRasterization().setEnabled(true);so.getRasterization().addAdvancedOption(AdvancedRasterizationOptions.Tilt,newHashMap<String,String>(){{put("minAngle","85");put("randomAngleMax","5");}});redactor.save(so);}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.