Browse our Products

If so you can download any of the below versions for testing. The product will function as normal except for an evaluation limitation. At the time of purchase we provide a license file via email that will allow the product to work in its full capacity. If you would also like an evaluation license to test without any restrictions for 30 days, please follow the directions provided here.


Product Docs Swagger Examples Blog Support Dashboard

Installation

The package is available at Packagist and it can be installed via Composer by executing following command:

composer require groupdocscloud/groupdocs-assembly-cloud

Packagist Version Packagist Downloads PHP-GroupDocsCloud


Requirements

  • PHP 5.5 or later
  • Composer
  • PHP extensions — curl, json, mbstring
  • GroupDocs Cloud credentials — Client ID and Client Secret from the Dashboard

Dependencies

The SDK requires the following packages:

PackageConstraint
guzzlehttp/guzzle^6.2
ext-curl*
ext-json*
ext-mbstring*

Quick Start

Get your API credentials

To use GroupDocs.Assembly Cloud, sign up at GroupDocs.Cloud Dashboard and get your Client ID and Client Secret.

Initialize the API

Use the following code to start using the GroupDocs.Assembly Cloud SDK for PHP:

<?php

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

// Get your ClientId and ClientSecret at https://dashboard.groupdocs.cloud
$assembly = new GroupDocs\Assembly\AssemblyApi("YourClientId", "YourClientSecret");
$assembly->getConfig()->setHost("https://api.groupdocs.cloud");

See BaseTestContext.php for more details.

Assemble a document from a template

Once initialized, use this basic example to build a document from a template already stored in GroupDocs Cloud and a local data file.

<?php

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

use GroupDocs\Assembly\Model;
use GroupDocs\Assembly\Model\Requests;

$assembly = new GroupDocs\Assembly\AssemblyApi("YourClientId", "YourClientSecret");
$assembly->getConfig()->setHost("https://api.groupdocs.cloud");

$reportData = file_get_contents("FileWithData");
$assembleData = new Model\AssembleOptions(array(
    "template_file_info" => new Model\TemplateFileInfo(array("file_path" => "FileNameInStorage")),
    "save_format" => "pdf",
    "report_data" => $reportData
));
$request = new Requests\AssembleDocumentRequest($assembleData);
$result = $assembly->assembleDocument($request);

echo "Assembled document size: " . $result->getSize() . "\n";

See the SDK README for more details.

Upload a Template and Assemble to PDF

This example uploads TableFeatures.odt, assembles it with TableData.json, and checks the result size.

<?php

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

use GroupDocs\Assembly\Model;
use GroupDocs\Assembly\Model\Requests;

$assembly = new GroupDocs\Assembly\AssemblyApi("YourClientId", "YourClientSecret");
$assembly->getConfig()->setHost("https://api.groupdocs.cloud");

$file = __DIR__ . "/TableFeatures.odt";
$remotePath = "Temp/SdkTests/php/GroupDocs/Assembly/TableFeatures.odt";

$assembly->uploadFile(new Requests\UploadFileRequest($file, $remotePath));

$reportData = file_get_contents(__DIR__ . "/TableData.json");
$assembleData = new Model\AssembleOptions(array(
    "template_file_info" => new Model\TemplateFileInfo(array("file_path" => $remotePath)),
    "save_format" => "pdf",
    "report_data" => $reportData
));
$request = new Requests\AssembleDocumentRequest($assembleData);
$result = $assembly->assembleDocument($request);

echo "Assembled document size: " . $result->getSize() . "\n";

See AssemblyApiTests.php for more details.

Get Supported File Formats

Retrieve the supported assembly file formats.

<?php

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

use GroupDocs\Assembly\Model\Requests;

$assembly = new GroupDocs\Assembly\AssemblyApi("YourClientId", "YourClientSecret");
$assembly->getConfig()->setHost("https://api.groupdocs.cloud");

$response = $assembly->getSupportedFileFormats(new Requests\GetSupportedFileFormatsRequest());

foreach ($response->getFileFormats()->getFormats() as $format) {
    echo $format->getFileFormat() . " - " . $format->getExtension() . "\n";
}

See GetSupportedFileFormatsRequest.php for more details.

Download a File from Cloud Storage

Download a file previously uploaded to storage.

<?php

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

use GroupDocs\Assembly\Model\Requests;

$assembly = new GroupDocs\Assembly\AssemblyApi("YourClientId", "YourClientSecret");
$assembly->getConfig()->setHost("https://api.groupdocs.cloud");

$request = new Requests\DownloadFileRequest("Temp/SdkTests/php/GroupDocs/Assembly/TableFeatures.odt");
$result = $assembly->downloadFile($request);

echo "Downloaded bytes: " . $result->getSize() . "\n";

See DownloadFileRequest.php for more details.

Examples on GitHub

The GroupDocs.Assembly Cloud PHP SDK repository includes the README example and tests covering:

CategoryExamples
Document AssemblyAssemble a document from a template on storage and a local data file
TestsUpload TestData/TableFeatures.odt and assemble it to PDF with TestData/TableData.json
File and format APISupported file formats, upload, and download

How to run the examples

  1. Install the package with composer require groupdocscloud/groupdocs-assembly-cloud
  2. Include Composer’s autoload with require_once('vendor/autoload.php');
  3. Put your credentials into Settings/servercreds.json
  4. Run the example usage from the README. Further examples are in tests

For more details, visit Getting Started.


Product Docs Swagger Examples Blog Support Dashboard


Tags

Document Automation | PHP Cloud API | GroupDocs.Assembly Cloud | REST API | Document Generation | Template Assembly | Report Generation | Mail Merge | JSON Data | Dynamic Data Merging | PDF Generation | Cloud Storage | File Upload API | Supported File Formats | Secure API Access



 English