PHPackages                             codeinc/document-cloud-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. codeinc/document-cloud-client

AbandonedArchivedLibrary[File &amp; Storage](/categories/file-storage)

codeinc/document-cloud-client
=============================

PHP Client for Code Inc.'s Document Cloud

v0.4(1y ago)03proprietaryPHPPHP &gt;=8.3

Since Dec 11Pushed 1y ago1 watchersCompare

[ Source](https://github.com/codeinchq/document-cloud-php-client)[ Packagist](https://packagist.org/packages/codeinc/document-cloud-client)[ Docs](https://github.com/codeinchq/document-cloud-php-client)[ RSS](/packages/codeinc-document-cloud-client/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (7)Versions (5)Used By (0)

PHP Client for Code Inc.'s Document Cloud
=========================================

[](#php-client-for-code-incs-document-cloud)

[![Code Inc.](https://camo.githubusercontent.com/ef47b2592fc4779ba27f8bd890b80b6fc951dcc9b1181fff7a340da506cd3f6d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f436f6465253230496e632e2d446f63756d656e74253230436c6f75642d626c7565)](https://www.codeinc.co)[![PHPUnit](https://github.com/codeinchq/document-cloud-php-client/actions/workflows/phpunit.yml/badge.svg)](https://github.com/codeinchq/document-cloud-php-client/actions/workflows/phpunit.yml)[![Packagist Version](https://camo.githubusercontent.com/86578541e50f8d2da234e4c6bfe00935659f460dd7477248330445a6c3cedd80/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636f6465696e632f646f63756d656e742d636c6f75642d636c69656e743f6c6162656c3d5061636b6167697374)](https://packagist.org/packages/codeinc/document-cloud-client)

Caution

It is a work in progress and is not yet ready for production use.

Installation
------------

[](#installation)

The library is available on [Packagist](https://packagist.org/packages/codeinc/document-cloud-client). The recommended way to install it is via Composer:

```
composer require codeinc/document-cloud-client
```

Available APIs
--------------

[](#available-apis)

### Office2Pdf API

[](#office2pdf-api)

This API allows you to convert office documents to PDF.

```
use CodeInc\DocumentCloud\Client;
use CodeInc\DocumentCloud\Office2Pdf\Office2Pdf;
use CodeInc\DocumentCloud\Office2Pdf\ConvertOptions;
use CodeInc\DocumentCloud\Office2Pdf\Format;
use CodeInc\DocumentCloud\Util\StreamUtils;
use CodeInc\DocumentCloud\Exception\UnsupportedFileTypeException;
use CodeInc\DocumentCloud\Exception\NetworkException;
use CodeInc\DocumentCloud\Exception\InvalidResponseException;
use CodeInc\DocumentCloud\Exception\FileOpenException;
use CodeInc\DocumentCloud\Exception\FileWriteException;

$srcDocPath = '/path/to/local/file.docx';
$destPdfPath = '/path/to/local/file.pdf';
$convertOption = new ConvertOptions(
    firstPage: 2,
    lastPage: 3,
    format: Format::json
);

$client = new Client('your-api-key'); // If the key is not specified, the library will try to get it from the `DOCUMENT_CLOUD_API_KEY` environment variable.
$office2Pdf = new Office2Pdf($client);

try {
    // convert
    $pdfStream = $office2Pdf->convert(
        StreamUtils::createStreamFromFile('/path/to/local/file.docx'),
        $convertOption
    );

   // save the PDF
   StreamUtils::saveStreamToFile($pdfStream, '/path/to/local/file.pdf');
}
catch (UnsupportedFileTypeException|NetworkException|InvalidResponseException|FileOpenException|FileWriteException $e) {
    // handle exception
}
```

#### Validating the support of a file format:

[](#validating-the-support-of-a-file-format)

```
use CodeInc\DocumentCloud\Client;
use CodeInc\DocumentCloud\Office2Pdf\Office2Pdf;

$client = new Client('your-api-key'); // If the key is not specified, the library will try to get it from the `DOCUMENT_CLOUD_API_KEY` environment variable.
$office2Pdf = new Office2Pdf($client);

$office2Pdf->supports('a-file.docx'); // returns true
$office2Pdf->supports('a-file'); // returns true
$office2Pdf->supports('a-file', false); // returns false (the second argument is the strict mode)
$office2Pdf->supports('a-file.pdf'); // returns false
```

### Pdf2Img API

[](#pdf2img-api)

This API allows you to convert PDF documents to images.

#### Base example:

[](#base-example)

```
use CodeInc\DocumentCloud\Client;
use CodeInc\DocumentCloud\Pdf2Img\Pdf2Img;
use CodeInc\DocumentCloud\Exception\NetworkException;
use CodeInc\DocumentCloud\Exception\InvalidResponseException;
use CodeInc\DocumentCloud\Exception\FileOpenException;
use CodeInc\DocumentCloud\Util\StreamUtils;

$client = new Client('your-api-key'); // If the key is not specified, the library will try to get it from the `DOCUMENT_CLOUD_API_KEY` environment variable.
$pdf2Img = new Pdf2Img($client);

try {
    // Open the PDF file
    $pdfStream = StreamUtils::createStreamFromFile('/path/to/local/file.pdf');

    // convert
    $imageStream = $pdf2Img->convert($pdfStream, $convertOption);

    // display the image
    header('Content-Type: image/webp');
    echo $imageStream->getContents();
}
catch (NetworkException|InvalidResponseException|FileOpenException $e) {
    // handle exception
}
```

#### With options:

[](#with-options)

```
use CodeInc\DocumentCloud\Client;
use CodeInc\DocumentCloud\Pdf2Img\Pdf2Img;
use CodeInc\DocumentCloud\Pdf2Img\Pdf2ImgConvertOptions;
use CodeInc\DocumentCloud\Pdf2Img\Pdf2ImgOutputFormat;
use CodeInc\DocumentCloud\Util\StreamUtils;
use CodeInc\DocumentCloud\Exception\NetworkException;
use CodeInc\DocumentCloud\Exception\InvalidResponseException;
use CodeInc\DocumentCloud\Exception\FileOpenException;
use CodeInc\DocumentCloud\Exception\FileWriteException;

$client = new Client('your-api-key'); // If the key is not specified, the library will try to get it from the `DOCUMENT_CLOUD_API_KEY` environment variable.
$pdf2Img = new Pdf2Img($client);

try {
    // Open the PDF file
    $pdfStream = StreamUtils::createStreamFromFile('/path/to/local/file.pdf');

    // Convert the PDF to an image
    $convertOption = new Pdf2ImgConvertOptions(
        format: Pdf2ImgOutputFormat::jpeg,
        page: 3,
        density: 300,
        height: 800,
        width: 800,
        background: 'red',
        quality: 90,
    );
    $imageStream = $pdf2Img->convert($pdfStream, $convertOption);

    // saves the image to a file
    StreamUtils::saveStreamToFile($imageStream, '/path/to/destination/file.jpg');
}
catch (NetworkException|InvalidResponseException|FileOpenException|FileWriteException $e) {
    // handle exception
}
```

### Pdf2Txt API

[](#pdf2txt-api)

This API allows you to convert PDF documents to text.

#### Extracting text from a local file:

[](#extracting-text-from-a-local-file)

```
use CodeInc\DocumentCloud\Client;
use CodeInc\DocumentCloud\Pdf2Txt\Pdf2Txt;
use CodeInc\DocumentCloud\Util\StreamUtils;
use CodeInc\DocumentCloud\Exception\NetworkException;
use CodeInc\DocumentCloud\Exception\InvalidResponseException;
use CodeInc\DocumentCloud\Exception\FileOpenException;
use CodeInc\DocumentCloud\Exception\FileWriteException;

$client = new Client('your-api-key'); // If the key is not specified, the library will try to get it from the `DOCUMENT_CLOUD_API_KEY` environment variable.
$pdf2Txt = new Pdf2Txt($client);

try {
    // Open the PDF file
    $pdfStream = StreamUtils::createStreamFromFile('/path/to/local/file.pdf');

    // Extract the textual content
    $textStream = $pdf2Txt->extract($pdfStream);

    // Display the textual content
    echo $textStream->getContents();
}
catch (NetworkException|InvalidResponseException|FileOpenException|FileWriteException $e) {
    // handle exception
}
```

#### With additional options:

[](#with-additional-options)

```
use CodeInc\DocumentCloud\Client;
use CodeInc\DocumentCloud\Pdf2Txt\Pdf2Txt;
use CodeInc\DocumentCloud\Util\StreamUtils;
use CodeInc\DocumentCloud\Exception\NetworkException;
use CodeInc\DocumentCloud\Exception\InvalidResponseException;
use CodeInc\DocumentCloud\Exception\FileOpenException;

$client = new Client('your-api-key'); // If the key is not specified, the library will try to get it from the `DOCUMENT_CLOUD_API_KEY` environment variable.
$pdf2Txt = new Pdf2Txt($client);

try {
    // Open the PDF file
    $pdfStream = StreamUtils::createStreamFromFile('/path/to/local/file.pdf');

    // Extract the textual content
    $convertOption = new ConvertOptions(
        firstPage: 2,
        lastPage: 3,
        format: Format::json
    );
    $jsonStream = $pdf2Txt->extract(
        $pdfStream,
        $convertOption
    );

   // Display the extracted text
   $decodedJson = json_decode($jsonStream->getContents(), true);
   var_dump($decodedJson);
}
catch (NetworkException|InvalidResponseException|FileOpenException $e) {
    // handle exception
}
```

#### Saving the extracted text to a file:

[](#saving-the-extracted-text-to-a-file)

```
use CodeInc\DocumentCloud\Client;
use CodeInc\DocumentCloud\Pdf2Txt\Pdf2Txt;
use CodeInc\DocumentCloud\Util\StreamUtils;
use CodeInc\DocumentCloud\Exception\NetworkException;
use CodeInc\DocumentCloud\Exception\InvalidResponseException;
use CodeInc\DocumentCloud\Exception\FileOpenException;
use CodeInc\DocumentCloud\Exception\FileWriteException;

$client = new Client('your-api-key'); // If the key is not specified, the library will try to get it from the `DOCUMENT_CLOUD_API_KEY` environment variable.
$pdf2Txt = new Pdf2Txt($client);

try {
    // Open the PDF file
    $pdfStream = StreamUtils::createStreamFromFile('/path/to/local/file.pdf');

    // Extract the textual content
    $textStream = $pdf2Txt->extract($pdfStream);

    // Save the textual content to a file
    StreamUtils::saveStreamToFile($textStream, '/path/to/local/file.txt');
}
catch (NetworkException|InvalidResponseException|FileOpenException|FileWriteException $e) {
    // handle exception
}
```

### Watermarker API

[](#watermarker-api)

This API allows you to add a watermark to a PDF document.

#### A simple scenario to apply a watermark to an image and display the result:

[](#a-simple-scenario-to-apply-a-watermark-to-an-image-and-display-the-result)

```
use CodeInc\DocumentCloud\Client;
use CodeInc\DocumentCloud\Watermarker\Watermarker;
use CodeInc\DocumentCloud\Util\StreamUtils;
use CodeInc\DocumentCloud\Exception\NetworkException;
use CodeInc\DocumentCloud\Exception\InvalidResponseException;
use CodeInc\DocumentCloud\Exception\FileOpenException;

$client = new Client('your-api-key'); // If the key is not specified, the library will try to get it from the `DOCUMENT_CLOUD_API_KEY` environment variable.
$watermaker = new Watermarker($client);

try {
    // Open the image and the watermark
    $anImageStream = StreamUtils::createStreamFromFile('/path/to/local/image.png');
    $theWatermarkStream = StreamUtils::createStreamFromFile('/path/to/local/watermark.png');

    // Apply the watermark
    $watermarkedImageStream = $watermaker->apply($anImageStream, $theWatermarkStream);

    // Display the watermarked image
    header('Content-Type: image/png');
    echo $watermarkedImageStream->getContents();
}
catch (NetworkException|InvalidResponseException|FileOpenException $e) {
    // handle exception
}
```

#### A mire complex scenario to apply a watermark to an image with options and save the result to a file:

[](#a-mire-complex-scenario-to-apply-a-watermark-to-an-image-with-options-and-save-the-result-to-a-file)

```
use CodeInc\DocumentCloud\Client;
use CodeInc\DocumentCloud\Watermarker\Watermarker;
use CodeInc\DocumentCloud\Watermarker\WatermarkerConvertOptions;
use CodeInc\DocumentCloud\Watermarker\WatermarkPosition;
use CodeInc\DocumentCloud\Watermarker\WatermarkerOutputFormat;
use CodeInc\DocumentCloud\Util\StreamUtils;
use CodeInc\DocumentCloud\Exception\NetworkException;
use CodeInc\DocumentCloud\Exception\InvalidResponseException;
use CodeInc\DocumentCloud\Exception\FileOpenException;
use CodeInc\DocumentCloud\Exception\FileWriteException;

$client = new Client('your-api-key'); // If the key is not specified, the library will try to get it from the `DOCUMENT_CLOUD_API_KEY` environment variable.
$watermaker = new Watermarker($client);

try {
    // Open the image and the watermark
    $anImageStream = StreamUtils::createStreamFromFile('/path/to/local/image.png');
    $theWatermarkStream = StreamUtils::createStreamFromFile('/path/to/local/watermark.png');

    // Apply the watermark
    $convertOption = new WatermarkerConvertOptions(
        size: 50,
        position: WatermarkPosition::topRight,
        format: WatermarkerOutputFormat::jpg,
        quality: 80,
        blur: 3,
        opacity: 75
    );
    $watermarkedImageStream = $client->apply($anImageStream, $theWatermarkStream, $convertOption);

    // save the watermarked image
    StreamUtils::saveStreamToFile($watermarkedImageStream, '/path/to/local/file.jpg');
}
catch (NetworkException|InvalidResponseException|FileOpenException|FileWriteException $e) {
    // handle exception
}
```

License
-------

[](#license)

The library is published under the MIT license (see [`LICENSE`](LICENSE) file).

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

524d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ce6d7fd91f537008e6af8eef5f5529e994cf74be8d78ee7b9d9ecac476ba1444?d=identicon)[joanfabregat](/maintainers/joanfabregat)

![](https://www.gravatar.com/avatar/8f72f949d7f70e400c02c225685f1934dec6219689f25edec38b4037df166d58?d=identicon)[codeinc](/maintainers/codeinc)

---

Top Contributors

[![joanfabregat](https://avatars.githubusercontent.com/u/4227907?v=4)](https://github.com/joanfabregat "joanfabregat (20 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/codeinc-document-cloud-client/health.svg)

```
[![Health](https://phpackages.com/badges/codeinc-document-cloud-client/health.svg)](https://phpackages.com/packages/codeinc-document-cloud-client)
```

###  Alternatives

[openai-php/client

OpenAI PHP is a supercharged PHP API client that allows you to interact with the Open AI API

5.8k22.6M232](/packages/openai-php-client)[mailgun/mailgun-php

The Mailgun SDK provides methods for all API functions.

1.1k28.9M168](/packages/mailgun-mailgun-php)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.5k311.5k5](/packages/theodo-group-llphant)[deeplcom/deepl-php

Official DeepL API Client Library

2616.2M66](/packages/deeplcom-deepl-php)[getbrevo/brevo-php

Official Brevo provided RESTFul API V3 php library

963.1M35](/packages/getbrevo-brevo-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
