Aspose.HTML Cloud SDK for .NET
Aspose.HTML Cloud for .NET is a programming SDK that allows software developers converting HTML documents to PDF, Image, XPS, DOCX.
Convert HTML to
- Fixed Layout: PDF, XPS, DOCX
- Images: TIFF, JPEG, PNG, BMP, GIF
- Other: MD, MHTML
Read HTML Formats
eBook: EPUB Other: XML, SVG
How to use the SDK?
The complete source code is available in this repository folder. You can either use it directly in your project via source code or get NuGet distribution (recommended). For more details, please visit our documentation website.
Prerequisites
To use Aspose HTML for Cloud .NET SDK register an account with Aspose Cloud and lookup/create Client ID
and Client Secret
at Cloud Dashboard. There is free quota available. For more details, see Aspose Cloud Pricing.
Installation
Get the ready package from NuGet or build from source available in this repository folder Aspose.HTML-Cloud.
Install Aspose.HTML-Cloud via NuGet
From the command line:
nuget install Aspose.HTML-Cloud
From Package Manager:
PM> Install-Package Aspose.HTML-Cloud
Run tests and examples
To run tests, firstly modify the Settings\servercreds.json file setting up your Client ID
& Client Secret
that you have obtained before (see Prerequisites) and basePath if it differs from http://api.aspose.cloud.
To run examples, modify the Aspose.HTML.Cloud.SDK.Examples\App.config file setting up ClientID, ClientSecret, and optionally DataPath.
Usage sample
The example below demonstrates how you can use the proposed SDK functionality in your application. In this example, the HTML document located by local path is converted to another format, e.g. PDF using Aspose.HTML-Cloud library.
How to try this code sample:
- Open Visual Studio and create an empty solution.
- In the solution, create a C# console application project.
- In the console project, install the last version of Aspose.HTML-Cloud package from NuGet ( see Install Aspose.HTML-Cloud via NuGet above ).
- Copy the code snippet below and replace Program.cs file content.
- Replace
ClientSecret
andClientId
variable values in the code with respective values from your account ( see Cloud Dashboard page ). - Run the application and check a result by the path displayed in the console output.
For more buildable and executable examples, refer the Documentation for API Endpoints chapter.
Basic example - convert local HTML file to required format
// Init client
var client = new HtmlApi("client_id", "client_secret").ConvertApi;
// Just provide path to source file and path to output file
// Convert HTML to PDF
await client.ConvertAsync("test.html", "test.pdf");
// Convert HTML to PNG
await client.ConvertAsync("test.html", "test.png");
// Convert HTML to DOC
await client.ConvertAsync("test.html", "test.doc");
// Convert HTML to XPS
await client.ConvertAsync("test.html", "test.xps");
Basic example - convert url to required format
// Init client
var client = new HtmlApi("client_id", "client_secret").ConvertApi;
// Just provide path to source file and path to output file
// Convert HTML to PDF
await client.ConvertUrlAsync("https://test.html", "test.pdf");
// Convert HTML to PNG
await client.ConvertUrlAsync("https://test.html", "test.png");
// Convert HTML to DOC
await client.ConvertUrlAsync("https://test.html", "test.doc");
// Convert HTML to XPS
await client.ConvertUrlAsync("https://test.html", "test.xps");
Dependencies
- .NET Standard 2.0 or later
- Newtonsoft.Json 12.0.2 or later
Aspose.HTML Cloud SDKs in Popular Languages
.NET | Java | PHP | Python | Ruby | Node.js | Android | Swift | C++ | Go |
---|---|---|---|---|---|---|---|---|---|
GitHub | GitHub | GitHub | GitHub | GitHub | GitHub | GitHub | GitHub | GitHub | GitHub |
NuGet | Maven | Composer | PIP | GEM | NPM | Maven | Cocoapods | NuGet | Go.Dev |
Product Page | Documentation | Code Samples | Blog | Free Support | Free Trial