PdfSaveOptions

PdfSaveOptions class

Specific data class provides few properties to manage conversion result. For example PageSetup specifies page characteristics. Refer to documentation article.

public class PdfSaveOptions : PdfRenderingOptions

Constructors

Name Description
PdfSaveOptions() The default constructor.

Properties

Name Description
BackgroundColor { get; set; } Gets or sets Color which will fill background of every page. Default value is Transparent.
Css { get; } Gets a CssOptions object which is used for configuration of css properties processing.
DocumentInfo { get; } Contains information about the output PDF document.
Encryption { get; set; } Gets or sets a encryption details. If not set, then no encryption will be performed.
virtual HorizontalResolution { get; set; } Sets or gets horizontal resolution for internal (which are used during filters processing) images, in pixels per inch. By default this property is 300 dpi.
JpegQuality { get; set; } Specifies the quality of JPEG compression for images (if JPEG compression is used). Default is 95.
PageSetup { get; } Gets a page setup object is used for configuration output page-set.
virtual VerticalResolution { get; set; } Sets or gets vertical resolution for internal (which are used during filters processing) images, in pixels per inch. By default this property is 300 dpi.

Remarks

You can find complete examples and data files on GitHub.

Examples

using Aspose.Html;
using Aspose.Html.Converters;
using Aspose.Html.Saving;
using System;
...
 	 // Prepare a path to a source HTML file
      string documentPath = Path.Combine(DataDir, "drawing.html");

      // Prepare a path for converted file saving 
      string savePath = Path.Combine(OutputDir, "drawing-options.pdf");

      // Initialize an HTML document from the file
      using var document = new HTMLDocument(documentPath);

      // Initialize PdfSaveOptions. Set up the page-size 600x300 pixels, margins, 
      // resolutions and change the background color to AliceBlue 
      var options = new PdfSaveOptions()
      {         
        HorizontalResolution = 200,
        VerticalResolution = 200,
        BackgroundColor = Color.AliceBlue,
        JpegQuality = 100
      };
      options.PageSetup.AnyPage = new Page(new Aspose.Html.Drawing.Size(600, 300), new Margin(20, 10, 10, 10));      

      // Convert HTML to PDF
      Converter.ConvertHTML(document, options, savePath);

See Also