Java library for communicating with the Aspose.HTML for Cloud API
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.settings
doc
docs
setting
src
testdata
.classpath
.gitignore
.project
LICENSE
README.md
pom.xml

README.md

Aspose HTML Cloud SDK

This repository contains Aspose.HTML Cloud SDK source code. This SDK allows you to work with Aspose.HTML Cloud REST APIs in your applications quickly and easily.

See API Reference for full API specification.

How to use the SDK?

The complete source code is available in this repository folder, you can either directly use it in your project.

Requirements

Building the API client library requires Maven to be installed.

Prerequisites

To use Aspose HTML for Cloud 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

To install the API client library to your local Maven repository, simply execute:

mvn install

To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:

mvn deploy

Refer to the official documentation for more information.

Maven users

Add this dependency to your project's POM:

<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-html-cloud</artifactId>
    <version>1.0.0</version>
    <scope>compile</scope>
</dependency>

Others

At first generate the JAR by executing:

mvn package

Then manually install the following JARs:

  • target/aspose-html-cloud-1.0.0.jar
  • target/lib/*.jar

Sample usage

Before fill all fields in /setting/config.json

Example:

{
    "basePath":"https://api.aspose.cloud/v1.1",
    "authPath":"https://api.aspose.cloud/oauth2/token",
    "apiKey":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "appSID":"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
    "storage":"\\data\\",
    "testdata":"\\testdata\\",
    "defaultUserAgent":"Webkit",
    "debug": false
}
import com.aspose.html.client.invoker.*;
import com.aspose.html.client.invoker.auth.*;
import com.aspose.html.client.api.ConversionApi;

import java.io.File;
import java.util.*;

public class ConversionApiExample {

    public static void main(String[] args) {
        
        ConversionApi apiInstance = new ConversionApi();
        String name = "name_example"; // String | Document name.
        String outFormat = "jpg"; // String | Resulting image format.
        Integer width = 800; // Integer | Resulting image width. 
        Integer height = 1000; // Integer | Resulting image height. 
        Integer leftMargin = 10; // Integer | Left resulting image margin.
        Integer rightMargin = 10; // Integer | Right resulting image margin.
        Integer topMargin = 10; // Integer | Top resulting image margin.
        Integer bottomMargin = 10; // Integer | Bottom resulting image margin.
        Integer xResolution = 300; // Integer | Horizontal resolution of resulting image.
        Integer yResolution = 300; // Integer | Vertical resolution of resulting image.
        String folder = "folder_example"; // String | The document folder.
        String storage = "storage_example"; // String | The document storage.
        try {
            File result = apiInstance.GetConvertDocumentToImage(name, outFormat, width, height, leftMargin, rightMargin, topMargin, bottomMargin, xResolution, yResolution, folder, storage);

    		//Save to test directory
    		File copyFile = new File("~/testdir/test.jpg");
    		result.renameTo(copyFile);
        } catch (ApiException e) {
            System.err.println("Exception when calling ConversionApi#GetConvertDocumentToImage");
            e.printStackTrace();
        }
    }
}

Documentation for API Endpoints

All URIs are relative to https://api.aspose.cloud/v1.1

ConversionApi

Method HTTP request Description
GetConvertDocumentToImage GET html/{name}/convert/image/{outFormat} Convert the HTML document from the storage by its name to the specified image format.
GetConvertDocumentToImageByUrl GET html/convert/image/{outFormat} Convert the HTML page from the web by its URL to the specified image format.
GetConvertDocumentToPdf GET html/{name}/convert/pdf Convert the HTML document from the storage by its name to PDF.
GetConvertDocumentToPdfByUrl GET html/convert/pdf Convert the HTML page from the web by its URL to PDF.
GetConvertDocumentToXps GET html/{name}/convert/xps Convert the HTML document from the storage by its name to XPS.
GetConvertDocumentToXpsByUrl GET html/convert/xps Convert the HTML page from the web by its URL to XPS.
PutConvertDocumentInRequestToImage PUT html/convert/image/{outFormat} Converts the HTML document (in request content) to the specified image format and uploads resulting file to storage.
PutConvertDocumentInRequestToPdf PUT html/convert/pdf Converts the HTML document (in request content) to PDF and uploads resulting file to storage.
PutConvertDocumentInRequestToXps PUT html/convert/xps Converts the HTML document (in request content) to XPS and uploads resulting file to storage.
PutConvertDocumentToImage PUT html/{name}/convert/image/{outFormat} Converts the HTML document (located on storage) to the specified image format and uploads resulting file to storage.
PutConvertDocumentToPdf PUT html/{name}/convert/pdf Converts the HTML document (located on storage) to PDF and uploads resulting file to storage.
PutConvertDocumentToXps PUT html/{name}/convert/xps Converts the HTML document (located on storage) to XPS and uploads resulting file to storage.

DocumentApi

Method HTTP request Description
GetDocumentFragmentByXPath GET html/{name}/fragments/{outFormat} Return list of HTML fragments matching the specified XPath query.
GetDocumentFragmentByXPathByUrl GET html/fragments/{outFormat} Return list of HTML fragments matching the specified XPath query by the source page URL.
GetDocumentFragmentsByCSSSelector GET /html/{name}/fragments/css/{outFormat} Return list of HTML fragments matching the specified CSS selector.
GetDocumentFragmentsByCSSSelectorByUrl GET /html/fragments/css/{outFormat} Return list of HTML fragments matching the specified CSS selector by the source page URL.
GetDocumentImages GET html/{name}/images/all Return all HTML document images packaged as a ZIP archive.
GetDocumentImagesByUrl GET html/images/all Return all HTML page images packaged as a ZIP archive by the source page URL.

OcrApi

Method HTTP request Description
GetRecognizeAndImportToHtml GET html/{name}/ocr/import Recognize text from the image file in the storage and import it to HTML format.
GetRecognizeAndTranslateToHtml GET html/{name}/ocr/translate/{srcLang}/{resLang} Recognize text from the image file in the storage, import it to HTML format and translate to specified language.

TranslationApi

Method HTTP request Description
GetTranslateDocument GET html/{name}/translate/{srcLang}/{resLang} Translate the HTML document specified by the name from default or specified storage.
GetTranslateDocumentByUrl GET html/translate/{srcLang}/{resLang} Translate the HTML document from Web specified by its URL.

SummarizationApi

Method HTTP request Description
GetDetectHtmlKeywords GET html/{name}/summ/keywords Get the HTML document keywords using the keyword detection service.
GetDetectHtmlKeywordsByUrl GET html/summ/keywords Get the keywords from HTML document from Web specified by its URL using the keyword detection service

TemplateMergeApi

Method HTTP request Description
GetMergeHtmlTemplate GET /html/{templateName}/merge Populate HTML document template with data located as a file in the storage.
PutMergeHtmlTemplate PUT /html/{templateName}/merge Populate HTML document template with data from the request body. Result document will be saved to storage.

Recommendation

It's recommended to create an instance of ApiClient per thread in a multithreaded environment to avoid any potential issues.

Examples

Tests contain various examples of using the Aspose.HTML SDK.

Docs Full javadoc for Aspose.HTML Api SDK