Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Nuget Nuget GitHub license

HTML Rendering & Conversion .NET Cloud REST API

Aspose.HTML Cloud for .NET is a programming SDK that allows software developers to manipulate and convert HTML documents from within their own applications. A Wrapper of RESTful APIs, Aspose.HTML Cloud for .NET speeds up HTML programming and conversion. This cloud SDK assists to develop cloud-based HTML page rendering, processing, translation & conversion apps in C#, ASP.NET & other .NET languages via REST API.

HTML Processing Features

  • Fetch the HTML page along with its resources as a ZIP archive by providing the page URL.
  • Based on page URL, retrieve all images of an HTML page as a ZIP package.
  • Load data from a local file to populate the HTML document template.
  • Use the request body to populate the HTML document template.
  • Convert HTML page to numerous other file formats.

Read & Write HTML Formats

HTML, XHTML, zipped HTML, zipped XHTML, MHTML, HTML containing SVG markup, Markdown, JSON

Save HTML As

Fixed Layout: PDF, XPS Images: TIFF, JPEG, PNG, BMP, GIF Other: TXT, ZIP (images)

Read HTML Formats

eBook: EPUB Other: XML, SVG

Enhancements Version 20.11

  • New generation of Aspose.HTML Cloud SDK for .NET (C#) is provided.
  • This version of SDK has been redesigned from scratch being based on the new Aspose.HTML Cloud REST API (v3.0).
  • Currently, it provides only the conversion feature. Other features that are still available in the versions up to v.20.08 are planned to be implemented in this SDK later.
  • Conversion interface provides a more flexible conversion parameters setup.
  • Redesigned storage access is provided using SDK entry point HtmlApi.Storage.
  • Availability of synchronous and asynchronous file upload and download methods.
  • Asynchronous download provides the ability to get progress data for the longer downloads.

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 you need to register an account with Aspose Cloud and lookup/create App Key and SID 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

From within Visual Studio:

  1. Open the Solution Explorer.
  2. Right-click on a project within your solution.
  3. Click on Manage NuGet Packages.
  4. Click on the Browse tab and search for "Aspose.HTML-Cloud".
  5. Click on the Aspose.HTML-Cloud package, select the appropriate version in the right-tab and click Install.

Run tests and examples

To run tests, firstly modify the Settings\servercreds.json file setting up your AppSID & AppKey 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 AppSID, AppKey, 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:

  1. Open Visual Studio and create an empty solution.
  2. In the solution, create a C# console application project.
  3. In the console project, install the last version of Aspose.HTML-Cloud package from NuGet ( see Install Aspose.HTML-Cloud via NuGet above ).
  4. Copy the code snippet below and replace Program.cs file content.
  5. Replace APPKEY and APPSID variable values in the code with respective values from your account ( see Cloud Dashboard page ).
  6. 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.

using Aspose.HTML.Cloud.Sdk;
using Aspose.HTML.Cloud.Sdk.Conversion;
using Aspose.HTML.Cloud.Sdk.Runtime.Core.Model;
using System;
using System.IO;

namespace ExamplesConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string AppSid = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
            string AppKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

            string appDir = AppDomain.CurrentDomain.BaseDirectory;
            string projPath = appDir.Substring(0, appDir.IndexOf("\\bin"));
            string sourceFile = Path.Combine(projPath, "TestSource", "test.html");

            // Creating api with credentials.
            var api = new HtmlApi(appSid : AppSid, appKey : AppKey);

            // Create converter by ConverterBuilder
            ConverterBuilder convHtmlPdf = new ConverterBuilder()
                .FromLocalFile(sourceFile)
                .To(new PDFConversionOptions())
                .SaveToLocal("TestResultDirectory");

            // Convert html page to pdf
            ConversionResult result = api.Convert(convHtmlPdf);

        }
    }
}

ConverterBuilder

From...

Specifies input data for conversion.

Possible conversions:

  • HTML -> PDF, XPS, JPEG, PNG, BMP, GIF, TIFF, MHTML, MD
  • XHTML -> PDF, XPS, JPEG, PNG, BMP, GIF, TIFF, MHTML, MD
  • MHTML -> HTML, PDF, XPS, JPEG, PNG, BMP, GIF, TIFF
  • EPUB -> PDF, XPS, JPEG, PNG, BMP, GIF, TIFF
Method Parameters Description
FromLocalFile(string inputPath) inputPath - path to a local file A source is a file in a local file system.
FromStorageFile(string inputPath) inputPath - path to the file in the cloud storage A source is a file in the cloud (user storage).
FromLocalDirectory(string inputDir, string startPoint, params string[] files) inputDir - path to the local directory
startPoint - name of the file for conversion
files - other files in the directory for conversion (optional)
Converts a file or files in a local directory with linked resources (css, image, etc.) in this directory.
FromLocalArchive(string inputPath, string startPoint, params string[] files) inputPath - path to a zip archive
startPoint - file in the archive for conversion
files - other files in the archive for conversion (optional)
A source with linked resources is a zip archive, located in a local file system.
FromStorageDirectory(string inputDir, string startPoint, params string[] files) inputDir - path to the directory in the storage
startPoint - name of the file for conversion
files - other files in the directory for conversion (optional)
Converts a file or files in a directory with linked resources (css, image, etc.) in this directory.
FromStorageArchive(string inputPath, string startPoint, params string[] files) inputPath - path to zip archive in the storage
startPoint - file in the archive for conversion
files - other files in the archive for conversion (optional)
A source with linked resources is a zip archive, located in the storage.
FromUrl(string urlAddress) urlAddress - web site for conversion A source gets from a URL.

To(ConversionOptions)

Specifies the output format for conversion.

Options Description
GIFConversionOptions Converting source file or URL to single or several images in GIF format.
JPEGConversionOptions Converting source file or URL to single or several images in JPEG format.
PNGConversionOptions Converting source file or URL to single or several images in PNG format.
TIFFConversionOptions Converting source file or URL to single or several images in TIFF format.
BMPConversionOptions Converting source file or URL to single or several images in BMP format.
PDFConversionOptions Converting source file or URL to PDF.
XPSConversionOptions Converting source file or URL to XPS.
MarkdownConversionOptions Converting source file or URL to Markdown.

SaveTo...

The target directory for a conversion result.

Method Parameters Description
SaveToLocal(string outputDirectory) outputDirectory - directory to save a result. A directory in the local file system to save a conversion result.
SaveToStorage(string outputDirectory) outputDirectory - directory to save a result. A directory in the cloud (user storage) to save a conversion result.

ConversionResult

Result object for conversion.

Field Description
string[] Files A list of conversion result files.
string Description A description in case of unsuccessful conversion.

Dependencies

.NET Standard 2.0 or later

Documentation for API Endpoints

The functionality provided by the SDK is divided into two groups:

  • HTML methods; represented by HtmlApi class.
  • Storage access methods; represented by StorageProvider class; the storage entry point is represented by an instance of StorageProvider that is available as HtmlApi.Storage property of the HtmlApi class.

All URIs are relative to https://api.aspose.cloud/v4.0.

Class: HtmlApi

Documentation for authorization methods

Since Aspose.HTML Cloud REST API currently supports only JWT authorization, SDK also uses JWT tokens to authorize REST API access.

For more details, see Authorization.


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 | API Reference | Code Samples | Blog | Free Support | Free Trial

About

.NET library for communicating with the Aspose.HTML Cloud API

Resources

License

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  
You can’t perform that action at this time.