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-07-23 20:02:49 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

conversionOptions

vectorizationOptions

STORAGE API

Documentation For Models

Documentation For Authorization

oauth

Examples

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

Author

Aspose