Convert XHTML to XPS – Cloud SDKs and REST API


Converting XHTML to XPS allows you to create high-quality, print-ready documents from web content. XPS is a fixed-layout document format designed to preserve documents’ layout, formatting, and graphical fidelity, making it suitable for printing and sharing with a consistent visual appearance across devices and platforms. By converting XHTML to XPS, you can create professional-quality documents that maintain the integrity of the original web content, including text, images, and styles, while ensuring compatibility with XPS-enabled applications and printers.

Aspose.HTML Cloud v4.0 provides the simplest API to convert XHTML documents to XPS format with high quality, easy and fast.

The article explains in a set of code examples how to convert an XHTML document to XPS using Aspose.HTML Cloud client SDKs and REST API calls. We will consider various scenarios of XHTML to XPS conversion. SDKs are available in PHP, C++, Ruby, Python, C#, Java, Android, Swift, and Node.js.

SDK Examples of XHTML to XPS Conversion

A widespread use case for Aspose.HTML Cloud SDK functions is file processing and converting. Cloud APIs allows you to fetch an XHTML document from a storage location by its name 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 XHTML to XPS for different cases using available SDKs and cURL.

Example 1. Convert XHTML to XPS with default conversion options

Consider converting an XHTML document initially located on a local file system to XPS format. The resultant file is then saved back to the local file system. The conversion occurs with default conversion options.

XHTML 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 XHTML to XPS with explicitly specified options

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

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

Example 3. Convert XHTML to XPS inside cloud storage

Aspose.HTML Cloud allows you to get an XHTML file from your cloud storage and save conversion result back to cloud storage. Let’s look at an example of conversion with default saving options.

See Also