HTML to image conversion
Aspose.HTML Cloud SDK for .NET produces a few quick and easy ways to convert HTML files to various image formats: by direct REST API calls or using SDKs. There are multiple image formats accessible for converting HTML documents with Aspose.HTML Cloud APIs - JPEG, PNG, BMP, GIF, and TIFF.
A cURL is one of the essential tools applied to receive or send data to a server and has a wide range of features. You can use cURL command-line instrument to access Aspose.HTML Cloud web services easily.
This example demonstrates how to convert HTML file located in the default cloud storage to an image format (JPEG in this example) with default parameters using the cURL utility (in the console, or using the system shell script - .bat file or PowerShell script in Windows, bash script in Linux etc.).
Step 1: Get JWT token for the user authentication
Step 2: Initialize an asynchronous conversion process using the POST method
Step 3: Check the previously started conversion process status using the GET method
An SDK integrates functionalities quickly, helps apps to perform better and be more stable. Using the Aspose.HTML Cloud SDK is the best way to speed up development.
Aspose.HTML Cloud SDK allows you to fetch HTML document from storage location by its name, from a URL or a local file on your drive, convert it to specified image format and save it to the storage or a local drive. The following code examples demonstrate how to convert HTML to images programmatically for different cases.
Case 1. Convert an HTML document from the storage by its name to JPEG and save to the storage
An example below shows how to convert HTML to JPEG using available SDKs. We consider the case when the source HTML document is in the storage, and you want to convert it to JPEG format and save to the storage.
In the example above, the conversion HTML to JPEG occurs with the ConversionOptions specifying, among which there is the Resolution that applicable only to image formats. More details about available conversion parameters for HTML files are in the SDK Conversion Options section.
Case 2. Convert a Web page by its URL to PNG and save to the local file system
Aspose.HTML Cloud SDK allows you to get HTML page from the web by its URL and convert it to the specified image format for saving to the local file system. The example below demonstrates how to convert HTML to PNG without conversion parameters specifying.
In the example, HTML to PNG conversion takes place with the default conversion options: the width and height of the resulting PNG image correspond to A4, all margins have zero value and resolution is 96 dpi.
Case 3. Convert a Web page by its URL to TIFF and save to the local file system
In the following example, HTML to TIFF conversion occurs with the conversion options setting. The set resolution value (300 dpi) indicates higher image quality than using the default value (96 dpi).
Case 4. Convert an HTML document from the storage by its name to BMP and save to the local file system
Let’s consider a common SDK usage scenario when the source document is in the storage, and you want to convert it to some other format and save to the local file system. In our example, it is HTML to BMP conversion.
Case 5. Convert an HTML document from the storage by its name to GIF and save to the storage
In the following example, we consider the case when the source HTML document is in the storage, and you want to convert it to GIF format and save to the storage.
In the example, HTML to GIF conversion occurs with the default conversion options: the width and height of the resulting PNG image correspond to A4, all margins have zero value and resolution is 96 dpi.
For more details, see Aspose.HTML for Cloud API Reference - is a collection of Swagger documentation for the Aspose.HTML Cloud APIs that provides testing and interactivity to our API endpoint documentation.