Convert HTML to XPS – Aspose.HTML Cloud SDK

Converting between formats is required for various reasons: to work in a familiar, convenient format or to take advantage of different formats for specific tasks. XPS is a document storage and viewing format developed by Microsoft. An XPS file is a ZIP archive using the Open Packaging Conventions containing the files that make up the document. It has a set of advantages that support security features, such as digital signatures to provide greater document security and more.

This article explains in a set of code examples how to convert HTML to XPS using Aspose.HTML Cloud.

Examples of HTML to XPS Conversion

Aspose.HTML Cloud allows you to fetch an HTML document from a storage location by its name, from a URL or a local file on your drive, convert it to a specified format and save it to the storage or a local drive. The following code examples demonstrate how to convert HTML to XPS for different cases using available SDKs and REST API.

Example 1. Convert HTML to XPS with default save options

Let’s look at an example of converting a local HTML file to XPS and saving the result to a local path.

HTML to XPS conversion occurs with the default conversion options: the resulting XPS document’s width and height correspond to A4, and all margins have zero value.

Example 2. Convert HTML to XPS with explicitly specified options

The example below demonstrates how to convert an HTML file from a local file system to XPS with explicitly specified options and save the result back to a local path.

More details about available conversion parameters for HTML files are in the SDK Conversion Options section.

Example 3. Convert a Web page to XPS

Aspose.HTML Cloud allows you to get an HTML page from the web by its URL, convert it to another format and save it into a local file system. The example below demonstrates how to convert HTML to XPS with the default conversion parameters.

HTML to XPS conversion occurs with the default conversion options: the resulting XPS document’s width and height correspond to A4, and all margins have zero value.

Example 4. Convert HTML to XPS inside cloud storage

Aspose.HTML Cloud allows you to get an HTML file from your cloud storage and save conversion result back to cloud storage.

See Also