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

Packagist Version Packagist Downloads PHP-GroupDocsCloud


Requirements

  • PHP 8.2 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.Editor 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.Editor Cloud SDK for PHP:

<?php

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

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

$editApi = new GroupDocs\Editor\EditApi($configuration);

See the full example in CommonUtils.php.

Edit a Word document

Once initialized, use this basic example to load a password-protected Word document, edit its HTML representation, and save the result.

<?php

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

use GroupDocs\Editor\Model;
use GroupDocs\Editor\Model\Requests;

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

$editApi = new GroupDocs\Editor\EditApi($configuration);
$fileApi = new GroupDocs\Editor\FileApi($configuration);

$fileInfo = new Model\FileInfo();
$fileInfo->setFilePath("WordProcessing/password-protected.docx");
$fileInfo->setPassword("password");

$loadOptions = new Model\WordProcessingLoadOptions();
$loadOptions->setFileInfo($fileInfo);
$loadOptions->setOutputPath("output");
$loadResult = $editApi->load(new Requests\loadRequest($loadOptions));

$htmlFile = $fileApi->downloadFile(new Requests\downloadFileRequest($loadResult->getHtmlPath()));
$html = file_get_contents($htmlFile->getRealPath());
$html = str_replace("Sample test text", "Hello world", $html);
file_put_contents($htmlFile->getRealPath(), $html);

$fileApi->uploadFile(new Requests\uploadFileRequest($loadResult->getHtmlPath(), $htmlFile->getRealPath()));

$saveOptions = new Model\WordProcessingSaveOptions();
$saveOptions->setFileInfo($fileInfo);
$saveOptions->setOutputPath("output/edited.docx");
$saveOptions->setHtmlPath($loadResult->getHtmlPath());
$saveOptions->setResourcesPath($loadResult->getResourcesPath());
$saveResult = $editApi->save(new Requests\saveRequest($saveOptions));

echo "Document edited: " . $saveResult->getPath() . "\n";

See the full example in EditWordProcessingDocument.php.

Edit a Spreadsheet Document

This example loads the first worksheet of an XLSX file, edits its HTML content, and saves the spreadsheet.

<?php

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

use GroupDocs\Editor\Model;
use GroupDocs\Editor\Model\Requests;

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

$editApi = new GroupDocs\Editor\EditApi($configuration);
$fileApi = new GroupDocs\Editor\FileApi($configuration);

$fileInfo = new Model\FileInfo();
$fileInfo->setFilePath("Spreadsheet/four-sheets.xlsx");

$loadOptions = new Model\SpreadsheetLoadOptions();
$loadOptions->setFileInfo($fileInfo);
$loadOptions->setOutputPath("output");
$loadOptions->setWorksheetIndex(0);
$loadResult = $editApi->load(new Requests\loadRequest($loadOptions));

$htmlFile = $fileApi->downloadFile(new Requests\downloadFileRequest($loadResult->getHtmlPath()));
$html = file_get_contents($htmlFile->getRealPath());
$html = str_replace("This is sample sheet", "This is sample sheep", $html);
file_put_contents($htmlFile->getRealPath(), $html);

$fileApi->uploadFile(new Requests\uploadFileRequest($loadResult->getHtmlPath(), $htmlFile->getRealPath()));

$saveOptions = new Model\SpreadsheetSaveOptions();
$saveOptions->setFileInfo($fileInfo);
$saveOptions->setOutputPath("output/edited.xlsx");
$saveOptions->setHtmlPath($loadResult->getHtmlPath());
$saveOptions->setResourcesPath($loadResult->getResourcesPath());
$saveResult = $editApi->save(new Requests\saveRequest($saveOptions));

echo "Document edited: " . $saveResult->getPath() . "\n";

See the full example in EditSpreadsheetDocument.php.

Get Document Information

Retrieve page count for a password-protected Word document.

<?php

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

use GroupDocs\Editor\Model;
use GroupDocs\Editor\Model\Requests;

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

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

$fileInfo = new Model\FileInfo();
$fileInfo->setFilePath("WordProcessing/password-protected.docx");
$fileInfo->setPassword("password");

$response = $infoApi->getInfo(new Requests\getInfoRequest($fileInfo));

echo "Page Count = " . $response->getPageCount() . "\n";

See the full example in GetDocumentInformation.php.

Get Supported File Types

Retrieve the supported file formats.

<?php

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

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

$infoApi = new GroupDocs\Editor\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.Editor Cloud PHP Examples repository includes ready-to-run examples covering:

CategoryExamples
File TypesSupported file types
Document InformationDocument information, license consumption
Edit Operations — WordEdit word processing documents, including password-protected files
Edit Operations — SpreadsheetEdit spreadsheet documents with worksheet selection
Edit Operations — PresentationEdit presentation documents with slide selection
Edit Operations — DSVEdit delimiter-separated values documents
Edit Operations — TextEdit plain text documents

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 Editing API | PHP Cloud API | GroupDocs.Editor Cloud | REST API | Word Processing Formats | Spreadsheet Formats | Presentation Formats | Text Formats | CSV Files | DOCX Documents | XLSX Documents | PPTX Presentations | Password-Protected Files | Cloud Storage Integration | Document Info Retrieval | File Operations | WYSIWYG Editing | Multi-Platform Support | Secure API Access | HTML Editing | Cross-platform API



 English