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-merger-cloud

Packagist Version Packagist Downloads PHP-GroupDocsCloud


Requirements

  • PHP 8.1 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.5.8 or ^7.4.5
ext-curl*
ext-json*
ext-mbstring*

Quick Start

Get your API credentials

To use GroupDocs.Merger 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.Merger Cloud SDK for PHP:

<?php

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

// Get your ClientId and ClientSecret at https://dashboard.groupdocs.cloud
$configuration = new GroupDocs\Merger\Configuration();
$configuration->setAppSid("YourClientId");
$configuration->setAppKey("YourClientSecret");
$configuration->setApiBaseUrl("https://api.groupdocs.cloud");

$documentApi = new GroupDocs\Merger\DocumentApi($configuration);

See the full example in CommonUtils.php.

Merge multiple documents

Once initialized, use this basic example to join Word documents from cloud storage into one file.

<?php

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

use GroupDocs\Merger\Model;
use GroupDocs\Merger\Model\Requests;

$configuration = new GroupDocs\Merger\Configuration();
$configuration->setAppSid("YourClientId");
$configuration->setAppKey("YourClientSecret");
$configuration->setApiBaseUrl("https://api.groupdocs.cloud");

$documentApi = new GroupDocs\Merger\DocumentApi($configuration);

$fileInfo1 = new Model\FileInfo();
$fileInfo1->setFilePath("WordProcessing/four-pages.docx");
$item1 = new Model\JoinItem();
$item1->setFileInfo($fileInfo1);

$fileInfo2 = new Model\FileInfo();
$fileInfo2->setFilePath("WordProcessing/one-page.docx");
$item2 = new Model\JoinItem();
$item2->setFileInfo($fileInfo2);

$options = new Model\JoinOptions();
$options->setJoinItems([$item1, $item2]);
$options->setOutputPath("Output/joined.docx");

$request = new Requests\joinRequest($options);
$response = $documentApi->join($request);

echo "Output file path: " . $response->getPath() . "\n";

See the full example in JoinMultipleDocuments.php.

Split a Document into Single Pages

This example splits a Word document into separate files for pages 1 and 3.

<?php

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

use GroupDocs\Merger\Model;
use GroupDocs\Merger\Model\Requests;

$configuration = new GroupDocs\Merger\Configuration();
$configuration->setAppSid("YourClientId");
$configuration->setAppKey("YourClientSecret");
$configuration->setApiBaseUrl("https://api.groupdocs.cloud");

$documentApi = new GroupDocs\Merger\DocumentApi($configuration);

$fileInfo = new Model\FileInfo();
$fileInfo->setFilePath("WordProcessing/sample-10-pages.docx");

$options = new Model\SplitOptions();
$options->setFileInfo($fileInfo);
$options->setOutputPath("Output/split-document");
$options->setPages([1, 3]);
$options->setMode(Model\SplitOptions::MODE_PAGES);

$request = new Requests\splitRequest($options);
$response = $documentApi->split($request);

echo "Documents count: " . count($response->getDocuments()) . "\n";

See the full example in SplitToSinglePages.php.

Rotate Document Pages

This example rotates selected pages in a PDF document.

<?php

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

use GroupDocs\Merger\Model;
use GroupDocs\Merger\Model\Requests;

$configuration = new GroupDocs\Merger\Configuration();
$configuration->setAppSid("YourClientId");
$configuration->setAppKey("YourClientSecret");
$configuration->setApiBaseUrl("https://api.groupdocs.cloud");

$pagesApi = new GroupDocs\Merger\PagesApi($configuration);

$fileInfo = new Model\FileInfo();
$fileInfo->setFilePath("Pdf/ten-pages.pdf");

$options = new Model\RotateOptions();
$options->setFileInfo($fileInfo);
$options->setOutputPath("Output/rotate-pages.pdf");
$options->setPages([2, 4]);
$options->setMode(Model\RotateOptions::MODE_ROTATE90);

$request = new Requests\rotateRequest($options);
$response = $pagesApi->rotate($request);

echo "Output file path: " . $response->getPath() . "\n";

See the full example in RotatePages.php.

Get Supported File Types

Retrieve the supported file types.

<?php

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

$configuration = new GroupDocs\Merger\Configuration();
$configuration->setAppSid("YourClientId");
$configuration->setAppKey("YourClientSecret");
$configuration->setApiBaseUrl("https://api.groupdocs.cloud");

$infoApi = new GroupDocs\Merger\InfoApi($configuration);

$response = $infoApi->getSupportedFileFormats();

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

See the full example in GetSupportedFileTypes.php.

Examples on GitHub

The GroupDocs.Merger Cloud PHP Examples repository includes ready-to-run examples covering:

CategoryExamples
InfoSupported file types, document information, license consumption
Document OperationsJoin multiple documents, cross-format join, join pages, join images, continuous Word join, mix pages, split documents, preview, import attachment
Pages OperationsExtract pages, move pages, remove pages, rotate pages, swap pages, change orientation
Security OperationsAdd, remove, and update a password; check password protection

How to run the examples

  1. Clone or download the examples repository
  2. Edit Examples/CommonUtils.php and set your ClientId and ClientSecret
  3. Go to the Examples directory
  4. Run composer update
  5. Execute php RunExamples.php

For more details, visit Getting Started.


Product Docs Swagger Examples Blog Support Dashboard


Tags

Document Merging API | PHP Cloud API | GroupDocs.Merger Cloud | REST API | Page Manipulation | Document Security | Password Protection | Cloud Storage Integration | File Operations | Folder Operations | Document Splitting | PDF Merging | Cross-format Merging | Word Document Merging | Excel File Merging | Presentation Merging | Document Reorganization | Secure API Access | Document Joining | Document Manipulation API | Merge Multiple Formats | Cross-platform API



 English