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
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Packagist Version Packagist PHP Version Support GitHub license GitHub last commit

HTML Rendering & Conversion PHP Cloud REST API

Aspose.HTML Cloud for PHP 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 PHP speeds up HTML programming and conversion. This cloud SDK assists to develop cloud-based HTML page rendering, processing, translation & conversion apps in PHP 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 directly use it in your project.

Requirements

PHP 5.6 and later

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 & Usage

Composer

To install the bindings via Composer, add the following to composer.json:

{
  "repositories": [
    {
      "type": "git",
      "url": "https://github.com/aspose-html-cloud/aspose-html-cloud-php.git"
    }
  ],
  "require": {
    "aspose/aspose-html-cloud-php": "dev-master"
  }
}

Then run composer install

Manual Installation

Download the files and include autoload.php:

    require_once('/path/to/aspose-html-cloud-php/vendor/autoload.php');

Getting Started

Example:
Pass configuration to constructor (see in tests - BaseTest.php)

        $conf = array(
            "basePath" => "https://api.aspose.cloud/v3.0",
            "authPath" => "https://api.aspose.cloud/connect/token",
            "apiKey" => "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            "appSID" => "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
            "testResult" => "\\testresult\\",
            "testData" => "\\testdata\\",
            "remoteFolder" => "HtmlTestDoc",
            "defaultUserAgent" => "Webkit",
            "debugFile" => "php://output",
            "debug" => false
        );

            self::$api_html = new HtmlApi($configuration);
            self::$api_stor = new StorageApi($configuration);

// optional for test
            self::$testFolder = realpath(__DIR__ . '/../..') . $configuration['testData'];
            self::$testResult = realpath(__DIR__ . '/../..') . $configuration['testResult'];

###Note: do not forget to add in php.ini

...
extension=php_openssl.dll
...
upload_max_filesize = 200M ; or 0 - unlimited
...
max_execution_time = 0 ; unlimited
...
default_socket_timeout = 3600 ; for long time operations

Tests

To run the unit tests:

composer install
./vendor/bin/phpunit

Please follow the installation procedure and then run the following:

<?php
require_once(__DIR__ . '/vendor/autoload.php');

$conf = array(
	"basePath" => "https://api.aspose.cloud/v3.0",
	"authPath" => "https://api.aspose.cloud/connect/token",
	"apiKey" => "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
	"appSID" => "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
	"testResult" => "\\testresult\\",
	"testData" => "\\testdata\\",
	"remoteFolder" => "HtmlTestDoc",
	"defaultUserAgent" => "Webkit",
	"debugFile" => "php://output",
	"debug" => false
);

$apiInstance = new Client\Invoker\Api\HtmlApi($conf);

$name = "name_example"; // string | Document name.
$out_format = "png"; // string | Resulting image format.
$width = 800; // int | Resulting image width.
$height = 1000; // int | Resulting image height.
$left_margin = 10; // int | Left resulting image margin.
$right_margin = 10; // int | Right resulting image margin.
$top_margin = 10; // int | Top resulting image margin.
$bottom_margin = 10; // int | Bottom resulting image margin.
$resolution = 300; // int | Resolution of resulting image.
$folder = "folder_example"; // string | The source document folder.
$storage = "storage_example"; // string | The source document storage.

try {
    $result = $apiInstance->getConvertDocumentToImage($name, $out_format, $width, $height, $left_margin, $right_margin, $top_margin, $bottom_margin, $resolution, $folder, $storage);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling HtmlApi->getConvertDocumentToImage: ', $e->getMessage(), PHP_EOL;
}

?>

Documentation for API Endpoints

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

HTML API

Class Method HTTP request Description
HtmlApi getConvertDocumentToImage GET /html/{name}/convert/image/{outFormat} Convert the HTML document from the storage by its name to the specified image format.
HtmlApi getConvertDocumentToImageByUrl GET /html/convert/image/{outFormat} Convert the HTML page from the web by its URL to the specified image format.
HtmlApi getConvertDocumentToPdf GET /html/{name}/convert/pdf Convert the HTML document from the storage by its name to PDF.
HtmlApi getConvertDocumentToPdfByUrl GET /html/convert/pdf Convert the HTML page from the web by its URL to PDF.
HtmlApi getConvertDocumentToXps GET /html/{name}/convert/xps Convert the HTML document from the storage by its name to XPS.
HtmlApi getConvertDocumentToXpsByUrl GET /html/convert/xps Convert the HTML page from the web by its URL to XPS.
HtmlApi postConvertDocumentInRequestToImage POST /html/convert/image/{outFormat} Converts the HTML document (in request content) to the specified image format and uploads resulting file to storage.
HtmlApi postConvertDocumentInRequestToPdf POST /html/convert/pdf Converts the HTML document (in request content) to PDF and uploads resulting file to storage.
HtmlApi postConvertDocumentInRequestToXps POST /html/convert/xps Converts the HTML document (in request content) to XPS and uploads resulting file to storage.
HtmlApi 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.
HtmlApi putConvertDocumentToPdf PUT /html/{name}/convert/pdf Converts the HTML document (located on storage) to PDF and uploads resulting file to storage.
HtmlApi putConvertDocumentToXps PUT /html/{name}/convert/xps Converts the HTML document (located on storage) to XPS and uploads resulting file to storage.
HtmlApi getConvertDocumentToMHTMLByUrl GET /html/convert/mhtml Converts the HTML page from Web by its URL to MHTML returns resulting file in response content.
HtmlApi getConvertDocumentToMarkdown GET /html/{name}/convert/md Converts the HTML document (located on storage) to Markdown and returns resulting file in response content.
HtmlApi postConvertDocumentInRequestToMarkdown POST /html/convert/md Converts the HTML document (in request content) to Markdown and uploads resulting file to storage by specified path.
HtmlApi putConvertDocumentToMarkdown PUT /html/{name}/convert/md Converts the HTML document (located on storage) to Markdown and uploads resulting file to storage by specified path.
HtmlApi getConvertMarkdownToHtml GET /html/{name}/import/md Converts the Markdown document (located on storage) to HTML and returns resulting file in response content.
HtmlApi postConvertMarkdownInRequestToHtml POST /html/import/md Converts the Markdown document (in request content) to HTML and uploads resulting file to storage by specified path.
HtmlApi putConvertMarkdownToHtml PUT /html/{name}/import/md Converts the Markdown document (located on storage) to HTML and uploads resulting file to storage by specified path.
HtmlApi getDocumentFragmentByXPath GET /html/{name}/fragments/{outFormat} Return list of HTML fragments matching the specified XPath query.
HtmlApi getDocumentByUrl GET /html/download Return all HTML page with linked resources packaged as a ZIP archive by the source page URL.
HtmlApi getDocumentFragmentByXPathByUrl GET /html/fragments/{outFormat} Return list of HTML fragments matching the specified XPath query by the source page URL.
HtmlApi getDocumentFragmentsByCSSSelector GET /html/{name}/fragments/css/{outFormat} Return list of HTML fragments matching the specified CSS selector.
HtmlApi getDocumentFragmentsByCSSSelectorByUrl GET /html/fragments/css/{outFormat} Return list of HTML fragments matching the specified CSS selector by the source page URL.
HtmlApi getDocumentImages GET /html/{name}/images/all Return all HTML document images packaged as a ZIP archive.
HtmlApi getDocumentImagesByUrl GET /html/images/all Return all HTML page images packaged as a ZIP archive by the source page URL.
HtmlApi getMergeHtmlTemplate GET /html/{templateName}/merge Populate HTML document template with data located as a file in the storage.
HtmlApi postMergeHtmlTemplate POST /html/{templateName}/merge Populate HTML document template with data from the request body. Result document will be saved to storage.
HtmlApi getSeoWarning GET /html/seo Page analysis and return of SEO warnings in json format.
HtmlApi getHtmlWarning GET /html/validator Checks the markup validity of Web documents in HTML, XHTML, etc., and return result in json format.

STORAGE API

Class Method HTTP request Description
StorageApi copyFile PUT /html/storage/file/copy/{srcPath} Copy file
StorageApi deleteFile DELETE /html/storage/file/{path} Delete file
StorageApi downloadFile GET /html/storage/file/{path} Download file
StorageApi moveFile PUT /html/storage/file/move/{srcPath} Move file
StorageApi uploadFile PUT /html/storage/file/{path} Upload file
StorageApi copyFolder PUT /html/storage/folder/copy/{srcPath} Copy folder
StorageApi createFolder PUT /html/storage/folder/{path} Create the folder
StorageApi deleteFolder DELETE /html/storage/folder/{path} Delete folder
StorageApi getFilesList GET /html/storage/folder/{path} Get all files and folders within a folder
StorageApi moveFolder PUT /html/storage/folder/move/{srcPath} Move folder
StorageApi getDiscUsage GET /html/storage/disc Get disc usage
StorageApi getFileVersions GET /html/storage/version/{path} Get file versions
StorageApi objectExists GET /html/storage/exist/{path} Check if file or folder exists
StorageApi storageExists GET /html/storage/{storageName}/exist Check if storage exists

Documentation For Models

Documentation For Authorization

oauth

Examples

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

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

PHP library for communicating with the Aspose.HTML Cloud API

Resources

License

Packages

No packages published

Languages

You can’t perform that action at this time.