RasterizationOptions

RasterizationOptions class

Provides options for converting files into PDF.

public class RasterizationOptions

Constructors

Name Description
RasterizationOptions() Initializes a new instance.

Properties

Name Description
Compliance { get; set; } Gets or sets the PDF Compliance level.
Enabled { get; set; } Gets or sets a value indicating whether all pages in the document need to be converted to images and put in a single PDF file. TRUE by default, set to FALSE in order to avoid rasterization.
HasAdvancedOptions { get; } Gets an indicator, which is true if advanced rasterization options are set.
PageCount { get; set; } Gets or sets the number of pages to be converted into PDF.
PageIndex { get; set; } Gets or sets the index of the first page (0-based) to convert into PDF.

Methods

Name Description
AddAdvancedOption(AdvancedRasterizationOptions) You can use this method to register an advanced rasterization option to apply.
AddAdvancedOption(AdvancedRasterizationOptions, Dictionary<string, string>) You can use this method to register an advanced rasterization option to apply.

Remarks

Learn more

Examples

The following example demonstrates how to set options for the rasterization process.

    using (var redactor = new Redactor("SomePresentation.pptx"))
    {
        // redact sensitive data on the first slide 
    
        var rasterizationOptions = new RasterizationOptions();
        rasterizationOptions.PageIndex = 0;
        rasterizationOptions.PageCount = 1;
        rasterizationOptions.Compliance = PdfComplianceLevel.PdfA1a;
        using (var stream = File.Open(Path.Combine(@"C:\Temp", "PresentationFirstSlide.pdf")))
        {
            redactor.Save(stream, rasterizationOptions);
        }
    }      

The following example demonstrates how to apply the advanced rasterization options with default settings.

    using (Redactor redactor = new Redactor(@"C:\sample.docx"))
    {
      // Save the document with default options (convert pages into images, save as PDF)
      var so = new SaveOptions();
      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);
    }

The following example demonstrates how to apply the border advanced rasterization option with custom settings.

    using (Redactor redactor = new Redactor(@"C:\sample.docx"))
    {
      // Save the document with a custom border
      var so = new SaveOptions();
      so.Rasterization.Enabled = true;
      so.RedactedFileSuffix = "_scan";
      so.Rasterization.AddAdvancedOption(AdvancedRasterizationOptions.Border, new Dictionary<string, string>() { { "border", "10" } });
      redactor.Save(so);
    }

The following example demonstrates how to apply the noise advanced rasterization option with custom settings.

    using (Redactor redactor = new Redactor(@"C:\sample.docx"))
    {
      // Save the document with the custom number and size of noise effects
      var so = new SaveOptions();
      so.Rasterization.Enabled = true;
      so.RedactedFileSuffix = "_scan";
      so.Rasterization.AddAdvancedOption(AdvancedRasterizationOptions.Noise, 
          new Dictionary<string, string>() { { "maxSpots", "150" }, { "spotMaxSize", "15" } });
      redactor.Save(so);
    }

The following example demonstrates how to apply the tilt advanced rasterization option with custom settings.

    using (Redactor redactor = new Redactor(@"C:\sample.docx"))
    {
      // Save the document with the custom tilt effect
      var so = new SaveOptions();
      so.Rasterization.Enabled = true;
      so.RedactedFileSuffix = "_scan";
      so.Rasterization.AddAdvancedOption(AdvancedRasterizationOptions.Tilt, 
          new Dictionary<string, string>() { { { "minAngle", "85" }, { "randomAngleMax", "5" } });
      redactor.Save(so);
    }

See Also