aspose/aspose-html-cloud-php

This repository contains Aspose_Html_Cloud_SDK for PHP source code. Aspose Cloud SDK for PHP lets PHP developers convert and process a variety of file formats in the cloud quickly and easily.

22.12.1 2022-12-13 12:39 UTC

This package is not auto-updated.

Last update: 2024-04-16 18:43:54 UTC


README

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

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/v4.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/v4.0",
	"authPath" => "https://api.aspose.cloud/connect/token",
	"apiKey" => "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
	"appSID" => "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
	"defaultUserAgent" => "Webkit"
);

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

// For PDF, XPS and DOCX formats the size is in inches, for images (JPEG, BMP, PNG, TIFF, GIF) - in pixels.
$options_a4 = [
    'width' => 8.3,
    'height' => 11.7,
    'left_margin' => 0.2,
    'right_margin' => 0.2,
    'top_margin' => 0.2,
    'bottom_margin' => 0.2
];

$src = 'https://stallman.org/articles/anonymous-payments-thru-phones.html';
$dst = 'website.pdf';

try {
    //Request to server Api
    $result = $apiInstance->convertUrlToLocal($src, $dst, $options_a4);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling HtmlApi->convertUrlToLocal: ', $e->getMessage(), PHP_EOL;
}

?>

Documentation for API Endpoints

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

Possible conversions:

  • HTML -> PDF, XPS, DOCX, MD, MHTML, JPEG, BMP, PNG, TIFF, GIF
  • EPUB -> PDF, XPS, DOCX, JPEG, BMP, PNG, TIFF, GIF
  • MD -> PDF, XPS, DOCX, HTML, MHTML, JPEG, BMP, PNG, TIFF, GIF
  • MHTML -> PDF, XPS, DOCX, JPEG, BMP, PNG, TIFF, GIF
  • SVG -> PDF, XPS, JPEG, BMP, PNG, TIFF, GIF
  • JPEG, BMP, PNG, TIFF, GIF -> SVG

HTML API

Class Method Description
HtmlApi convertLocalToLocal Convert a document from the local file to the local file.
HtmlApi convertLocalToStorage Convert a document from the local file to the storage.
HtmlApi convertStorageToLocal Convert a document from the storage to the local file.
HtmlApi convertStorageToStorage Convert a document from the storage to the storage.
HtmlApi convertUrlToLocal Convert the website and saving result to the local file.
HtmlApi convertUrlToStorage Convert the website and saving result to the storage.
HtmlApi convert General function for conversion.
HtmlApi vectorizeLocalToLocal Vectorize an image from the local file to the local file.
HtmlApi vectorizeLocalToStorage Vectorize an image from the local file to the storage.
HtmlApi vectorizeStorageToLocal Vectorize an image from the storage to the local file.
HtmlApi vectorizeStorageToStorage Vectorize an image from the storage to the storage.
HtmlApi vectorize General function for vectorization.

conversionOptions

Options Description
PDFOptions Convert to the PDF format.
ImageOptions Convert to images (JPEG, PNG, GIF, TIFF, BMP).
XPSOptions Convert to the XPS format.
DocOptions Convert to the DOCX format.
SvgOptions Trace images to the SVG format.
MarkdownOptions Convert the HTML document to the markdown format.

vectorizationOptions

Field Type Description Note
error_threshold float This parameter defines maximum deviation of points to fitted curve. By default it is 30. Optional
max_iterations int This parameter defines number of iteration for least-squares approximation method. By default it is 30. Optional
colors_limit int The maximum number of colors used to quantize an image. Default value is 25. Optional
line_width float The value of this parameter is affected by the graphics scale. Default value is 1. Optional

STORAGE API

Class Method Description
StorageApi deleteFile Delete file
StorageApi downloadFile Download file
StorageApi uploadFile Upload file
StorageApi createFolder Create the folder
StorageApi deleteFolder Delete folder
StorageApi getFilesList Get all files and folders within a folder
StorageApi getDiscUsage Get disc usage
StorageApi objectExists Check if file or folder exists
StorageApi storageExists Check if storage exists

Documentation For Models

Documentation For Authorization

oauth

Examples

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

Author

Aspose