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-parser-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.Parser 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.Parser Cloud SDK for PHP:

<?php

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

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

$parseApi = new GroupDocs\Parser\ParseApi($configuration);

See the full example in Utils.php.

Extract text from a document

Once initialized, use this basic example to extract text from a document in cloud storage.

<?php

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

use GroupDocs\Parser\Model;
use GroupDocs\Parser\Model\Requests;

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

$parseApi = new GroupDocs\Parser\ParseApi($configuration);

$options = new Model\TextOptions();

$fileInfo = new Model\FileInfo();
$fileInfo->setFilePath("email/eml/embedded-image-and-attachment.eml");
$options->setFileInfo($fileInfo);

$request = new Requests\textRequest($options);
$result = $parseApi->text($request);

echo "Text: " . $result->getText() . "\n";

See the full example in ExtractTextFromTheWholeDocument.php.

Get Supported File Formats

Retrieve the supported file formats.

<?php

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

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

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

$result = $infoApi->getSupportedFileFormats();

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

See the full example in GetSupportedFileTypes.php.

Parse a Document by Template

This example parses a document with a template stored in cloud storage and reads text fields and table cells.

<?php

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

use GroupDocs\Parser\Model;
use GroupDocs\Parser\Model\Requests;

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

$parseApi = new GroupDocs\Parser\ParseApi($configuration);

$options = new Model\ParseOptions();

$fileInfo = new Model\FileInfo();
$fileInfo->setFilePath("words-processing/docx/companies.docx");
$options->setFileInfo($fileInfo);
$options->setTemplatePath("templates/companies.json");

$request = new Requests\parseRequest($options);
$result = $parseApi->parse($request);

foreach ($result->getFieldsData() as $data) {
    if ($data->getPageArea()->getPageTextArea() != null) {
        echo "Field name: " . $data->getName() . ". Text: " . $data->getPageArea()->getPageTextArea()->getText() . "\n";
    }

    if ($data->getPageArea()->getPageTableArea() != null) {
        echo "Table name: " . $data->getName() . "\n";
        foreach ($data->getPageArea()->getPageTableArea()->getPageTableAreaCells() as $cell) {
            echo "Row " . $cell->getRowIndex() . " column " . $cell->getColumnIndex() . ": " . $cell->getPageArea()->getPageTextArea()->getText() . "\n";
        }
    }
}

See the full example in ParseByTemplateStoredInUserStorage.php.

Extract Images from a Document

This example extracts embedded images from a presentation and prints each storage path and download URL.

<?php

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

use GroupDocs\Parser\Model;
use GroupDocs\Parser\Model\Requests;

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

$parseApi = new GroupDocs\Parser\ParseApi($configuration);

$options = new Model\ImagesOptions();

$fileInfo = new Model\FileInfo();
$fileInfo->setFilePath("slides/three-slides.pptx");
$options->setFileInfo($fileInfo);

$request = new Requests\imagesRequest($options);
$result = $parseApi->images($request);

foreach ($result->getImages() as $image) {
    echo "Image path: " . $image->getPath() . ". Download url: " . $image->getDownloadUrl() . "\n";
    echo "Format: " . $image->getFileFormat() . ". Page index: " . $image->getPageIndex() . "\n";
}

See the full example in ExtractImagesFromTheWholeDocument.php.

Examples on GitHub

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

CategoryExamples
InfoSupported file formats, document information, container items
Extract TextWhole document, formatted text, page number range, document inside a container
Extract ImagesWhole document, page number range, document inside a container
Parse by TemplateTemplate stored in user storage, template defined as an object, document inside a container
Parse by AIParse a document by AI with a template
TemplatesCreate or update, get, and delete a template

How to run the examples

  1. Clone or download the examples repository
  2. Edit Examples/Utils.php and set your AppSid and AppKey
  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 Data Extraction | PHP Cloud API | GroupDocs.Parser Cloud | REST API | Text Extraction | Image Extraction | Template Parsing | Data Parsing | Document Information | Container Files | Cloud Storage Integration | File Operations | Folder Operations | Secure API Access | Document Parsing | Metadata Extraction | PDF Parsing | ZIP Files | PST/OST Files | Cross-platform API | Document Processing | Data Extraction API



 English