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.
constredaction=require('@groupdocs/groupdocs.redaction');constredactor=newredaction.Redactor('Sample.docx');try{// Save the document with advanced options (convert pages into images, and save PDF with scan-like pages)
constso=newredaction.SaveOptions();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();}
sample.docx is the sample file used in this example. Click here to download it.
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.
constredaction=require('@groupdocs/groupdocs.redaction');constredactor=newredaction.Redactor('Sample.docx');try{// Save the document with a custom border
constso=newredaction.SaveOptions();so.setRedactedFileSuffix('_scan');so.getRasterization().setEnabled(true);so.getRasterization().addAdvancedOption(AdvancedRasterizationOptions.Border,newHashMap<String,String>(){{put('border','10');}});redactor.save(so);}finally{redactor.close();}
sample.docx is the sample file used in this example. Click here to download it.
The following example demonstrates how to apply the grayscale advanced rasterization option.
constredaction=require('@groupdocs/groupdocs.redaction');constredactor=newredaction.Redactor('Sample.docx');try{// Save the document converting it to a grayscale
constso=newredaction.SaveOptions();so.setRedactedFileSuffix('_scan');so.getRasterization().setEnabled(true);so.getRasterization().addAdvancedOption(AdvancedRasterizationOptions.Grayscale);redactor.save(so);}finally{redactor.close();}
sample.docx is the sample file used in this example. Click here to download it.
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.
constredaction=require('@groupdocs/groupdocs.redaction');constredactor=newredaction.Redactor('Sample.docx');try{// Save the document with the custom number and size of noise effects
constso=newredaction.SaveOptions();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();}
sample.docx is the sample file used in this example. Click here to download it.
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.
constredaction=require('@groupdocs/groupdocs.redaction');constredactor=newredaction.Redactor('Sample.docx');try{// Save the document with the custom tilt effect
constso=newredaction.SaveOptions();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();}
sample.docx is the sample file used in this example. Click here to download it.