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.11.1 2022-11-14 10:58 UTC

This package is not auto-updated.

Last update: 2022-11-28 11:11:41 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 = self::$api_html->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 the HTML or EPUB document from the local file to the local file.
HtmlApi convertLocalToStorage Convert the HTML or EPUB document from the local file to the storage.
HtmlApi convertStorageToLocal Convert the HTML or EPUB document from the storage to the local file.
HtmlApi convertStorageToStorage Convert the HTML or EPUB 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.

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.

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