Convert MHTML to PDF - Cloud SDKs and REST API


PDF is a static document that can contain text, images, form-fields, media, digital signatures, hyperlinks, etc. MHTML to PDF conversion preserves layout and formatting while enabling offline access, sharing, and printing of web content. PDF files retain a visual representation of the original MHTML content, making them suitable for viewing on various devices and platforms without an Internet connection. PDF’s extensive interoperability and security capabilities also enhance document sharing and distribution, allowing users to control access and protect sensitive information.

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

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

  • Converting a local MHTML file to PDF and saving the result in your local file system. In this scenario, we will explore both conversions with default conversion parameters and with explicitly specified parameters.
  • Converting MHTML to PDF in cloud storage with default conversion parameters.

Examples of MHTML to PDF Conversion

A widespread use case for Aspose.HTML Cloud functions is file processing and converting. Cloud SDK allows you to fetch an MHTML document from a storage location by its name or from a local file on your drive, convert it to a specified format, and save it to storage or the local drive. The following code examples demonstrate how to convert MHTML to PDF for different cases using available SDKs and REST API.

Example 1. Convert MHTML to PDF with default save options

Let’s look at an example of converting a local MHTML file to PDF and saving the result to a local file system. The conversion occurs with default conversion options.

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

Example 2. Convert MHTML to PDF with explicitly specified options

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

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

Example 3. Convert MHTML to PDF inside cloud storage

Aspose.HTML Cloud allows you to get an MHTML file from your cloud storage and save conversion result back to cloud storage. The conversion occurs with default conversion options.

See Also