XpsSaveOptions Class

XpsSaveOptions class

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

public class XpsSaveOptions : XpsRenderingOptions

Constructors

NameDescription
XpsSaveOptions()The default constructor.

Properties

NameDescription
[getBackgroundColor]
[setBackgroundColor] Gets or sets Color which will fill background of every page. Default value is Transparent.
getCss Gets a CssOptions object which is used for configuration of css properties processing.
[getHorizontalResolution]
[setHorizontalResolution] 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.
getPageSetup Gets a page setup object is used for configuration output page-set.
[getVerticalResolution]
[setVerticalResolution] 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

import com.aspose.html;
import com.aspose.html.Converters;
import com.aspose.html.Saving;
import System;
...
	  String documentPath = Path.Combine(OutputDir, "save-options.html");
      String savePath = Path.Combine(OutputDir, "save-options-output.xps");

      // Prepare HTML code and save it to a file
      var code = "<h1> XpsSaveOptions Class</h1>\r\n" +
            "<p>Using XpsSaveOptions Class, you can programmatically apply a wide range of conversion parameters such as BackgroundColor, PageSetup, etc.</p>\r\n";

      File.WriteAllText(documentPath, code);

      // Initialize an HTML Document from the html file
      using var document = new HTMLDocument(documentPath);
       
      // Set up the page-size, margins and change the background color to AntiqueWhite
      var options = new XpsSaveOptions()
      {
        BackgroundColor = Color.AntiqueWhite
      };
      options.PageSetup.AnyPage = new Page(new com.aspose.html.Drawing.Size(Length.FromInches(4.9f), Length.FromInches(3.5f)), new Margin(30, 20, 10, 10));

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

See Also