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.
using(Redactorredactor=newRedactor(@"sample.docx")){// Save the document with advanced options (convert pages into images, and save PDF with scan-like pages)varso=newSaveOptions();so.Rasterization.Enabled=true;so.RedactedFileSuffix="_scan";so.Rasterization.AddAdvancedOption(AdvancedRasterizationOptions.Border);so.Rasterization.AddAdvancedOption(AdvancedRasterizationOptions.Noise);so.Rasterization.AddAdvancedOption(AdvancedRasterizationOptions.Grayscale);so.Rasterization.AddAdvancedOption(AdvancedRasterizationOptions.Tilt);redactor.Save(so);}
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.
C#
using(Redactorredactor=newRedactor(@"sample.docx")){// Save the document with a custom bordervarso=newSaveOptions();so.Rasterization.Enabled=true;so.RedactedFileSuffix="_scan";so.Rasterization.AddAdvancedOption(AdvancedRasterizationOptions.Border,newDictionary<string,string>(){{"border","10"}});redactor.Save(so);}
Use grayscale rasterization option
The following example demonstrates how to apply the grayscale advanced rasterization option.
C#
using(Redactorredactor=newRedactor(@"sample.docx")){// Save the document with the custom grayscale effectvarso=newSaveOptions();so.Rasterization.Enabled=true;so.RedactedFileSuffix="_scan";so.Rasterization.AddAdvancedOption(AdvancedRasterizationOptions.Grayscale);redactor.Save(so);}
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.
C#
using(Redactorredactor=newRedactor(@"sample.docx")){// Save the document with the custom number and size of noise effectsvarso=newSaveOptions();so.Rasterization.Enabled=true;so.RedactedFileSuffix="_scan";so.Rasterization.AddAdvancedOption(AdvancedRasterizationOptions.Noise,newDictionary<string,string>(){{"maxSpots","150"},{"spotMaxSize","15"}});redactor.Save(so);}
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.
C#
using(Redactorredactor=newRedactor(@"sample.docx")){// Save the document with the custom tilt effectvarso=newSaveOptions();so.Rasterization.Enabled=true;so.RedactedFileSuffix="_scan";so.Rasterization.AddAdvancedOption(AdvancedRasterizationOptions.Tilt,newDictionary<string,string>(){{"minAngle","85"},{"randomAngleMax","5"}});redactor.Save(so);}
More resources
GitHub examples
You may easily run the code above and see the feature in action in our GitHub examples:
Along with full featured .NET library we provide simple, but powerful free Apps.
You are welcome to perform redactions for various document formats like PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX, Emails and more with our free online Free Online Document Redaction App.
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.