PHPackages                             pdfen/php-sdk - 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. [API Development](/categories/api)
4. /
5. pdfen/php-sdk

ActiveLibrary[API Development](/categories/api)

pdfen/php-sdk
=============

Official PHP SDK for PDFen.com API v2

2.1.0(2mo ago)02MITPHPPHP ^8.1

Since Dec 11Pushed 2mo agoCompare

[ Source](https://github.com/PDFen/php-sdk)[ Packagist](https://packagist.org/packages/pdfen/php-sdk)[ RSS](/packages/pdfen-php-sdk/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (8)Versions (3)Used By (0)

PDFen PHP SDK (v2)
==================

[](#pdfen-php-sdk-v2)

Official PHP SDK for the PDFen.com API v2.

[![PHP Version](https://camo.githubusercontent.com/7663c9d53dc13cedaf0660a8745a7e77d2dd711257f36aa86ebce12a0600ef42/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e312d626c75652e737667)](https://www.php.net/)[![License](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](LICENSE)

Features
--------

[](#features)

- ✅ Full V2 API support
- ✅ AI-powered data extraction (invoice, email, form, table, legal, floor plan)
- ✅ Laravel Sanctum authentication
- ✅ Type-safe responses
- ✅ Fluent API interface
- ✅ Async &amp; sync conversion modes
- ✅ File upload helpers
- ✅ Exception handling
- ✅ PSR-4 compliant

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

[](#installation)

```
composer require pdfen/php-sdk
```

Quick Start
-----------

[](#quick-start)

```
use Pdfen\Sdk\PdfenClient;

// Initialize client with API token
$client = new PdfenClient('your-api-token');

// Get user info
$user = $client->user()->get();
echo "Available credits: {$user->credits}\n";

// Convert a file (async mode)
$conversion = $client->convert()
    ->files(['document.docx'])
    ->workflow(1) // workflow ID
    ->async()
    ->execute();

echo "Execution ID: {$conversion->executionId}\n";

// Check status
$status = $client->executions()->get($conversion->executionId);
echo "Status: {$status->status}\n";

// Download when complete
if ($status->isCompleted()) {
    $client->executions()->download($conversion->executionId, 'output.pdf');
    echo "Downloaded to output.pdf\n";
}
```

Usage Examples
--------------

[](#usage-examples)

### Synchronous Conversion

[](#synchronous-conversion)

```
$conversion = $client->convert()
    ->files(['image.jpg'])
    ->workflow(2)
    ->sync() // Wait for completion
    ->execute();

if ($conversion->isCompleted()) {
    $client->executions()->download($conversion->executionId, 'result.pdf');
}
```

### Multiple Files with Options

[](#multiple-files-with-options)

```
$conversion = $client->convert()
    ->files(['doc1.docx', 'doc2.docx', 'image.jpg'])
    ->workflow(1)
    ->options([
        'convert_metadata' => true,
        'page_size' => 'a4'
    ])
    ->async()
    ->execute();

echo "Credits charged: {$conversion->creditsCharged}\n";
echo "Credits remaining: {$conversion->creditsRemaining}\n";
```

### Conversion with Advanced Options

[](#conversion-with-advanced-options)

```
// PDF to Word with page range and password
$conversion = $client->convert()
    ->files(['document.pdf'])
    ->workflow(10) // PDF to Word workflow
    ->options([
        'page_range' => '1-10,15-20',
        'output_format' => 'docx',
        'password' => 'secret123', // If PDF is password-protected
        'ocr' => true,
        'ocr_language' => 'nld'
    ])
    ->async()
    ->execute();

// Get available options for a workflow
$options = $client->workflows()->options(10);
foreach ($options->options as $option) {
    echo "{$option->key}: {$option->name}\n";
}
```

### Cover Page Templates

[](#cover-page-templates)

```
// Get available cover templates
$templates = $client->user()->coverTemplates();

foreach ($templates->templates as $template) {
    echo "Template: {$template->name} (ID: {$template->template_id})\n";
}

// Use cover template in conversion
$conversion = $client->convert()
    ->files(['document.pdf'])
    ->workflow(5)
    ->coverTemplateId(123) // Use cover template ID 123
    ->execute();
```

### List Available Workflows

[](#list-available-workflows)

```
$workflows = $client->user()->workflows();

foreach ($workflows->userWorkflows as $workflow) {
    echo "- {$workflow->name} (ID: {$workflow->id})\n";
}
```

### Check Credits

[](#check-credits)

```
$credits = $client->user()->credits();

echo "Personal credits: {$credits->personalCredits}\n";
echo "Organization credits: {$credits->organizationCredits}\n";
echo "Total available: {$credits->totalAvailable}\n";
```

Data Extraction
---------------

[](#data-extraction)

Extract structured data from documents using AI. Each extraction type returns JSON by default, or can download as CSV/Excel.

### Invoice Extraction

[](#invoice-extraction)

```
$result = $client->extract()
    ->files(['invoice.pdf'])
    ->locale('nl')
    ->invoice();

echo "Credits charged: {$result->creditsCharged}\n";

foreach ($result->results as $file) {
    foreach ($file['invoices'] as $invoice) {
        echo "{$invoice['vendor_name']}: {$invoice['total']}\n";
    }
}

// Download as CSV
$client->extract()
    ->files(['invoice.pdf'])
    ->format('csv')
    ->invoiceDownload('/tmp/invoices.csv');
```

### Email Extraction

[](#email-extraction)

```
$result = $client->extract()
    ->files(['message.eml'])
    ->email();

foreach ($result->results as $file) {
    foreach ($file['emails'] as $email) {
        echo "{$email['subject']}: {$email['from']['email']}\n";
    }
}
```

### Form, Table, Legal Extraction

[](#form-table-legal-extraction)

```
// Forms - extracts field names and values
$result = $client->extract()->files(['form.pdf'])->form();

// Tables - extracts tabular data
$result = $client->extract()->files(['report.pdf'])->table();

// Legal - extracts clauses, parties, dates
$result = $client->extract()->files(['contract.pdf'])->legal();
```

### Floor Plan Extraction

[](#floor-plan-extraction)

```
$result = $client->extract()
    ->files(['floorplan.pdf'])
    ->template('full_detail') // room_overview, dimensions, or full_detail
    ->floorPlan();

foreach ($result->results as $file) {
    foreach ($file['rooms'] ?? [] as $room) {
        echo "{$room['name']}: {$room['area']} m²\n";
    }
}
```

### Download Formats

[](#download-formats)

All extraction types support binary download (CSV, Excel). Invoice also supports UBL:

```
$client->extract()->files(['data.pdf'])->format('excel')->tableDownload('/tmp/tables.xlsx');
$client->extract()->files(['invoice.pdf'])->format('ubl')->invoiceDownload('/tmp/invoice.xml');
```

Error Handling
--------------

[](#error-handling)

```
use Pdfen\Sdk\Exceptions\InsufficientCreditsException;
use Pdfen\Sdk\Exceptions\ValidationException;
use Pdfen\Sdk\Exceptions\AuthenticationException;

try {
    $conversion = $client->convert()
        ->files(['large-file.pdf'])
        ->workflow(1)
        ->execute();

} catch (InsufficientCreditsException $e) {
    echo "Not enough credits: {$e->getMessage()}\n";
    echo "Credits needed: {$e->getCreditsNeeded()}\n";
    echo "Credits available: {$e->getCreditsAvailable()}\n";

} catch (ValidationException $e) {
    echo "Validation error: {$e->getMessage()}\n";
    print_r($e->getErrors());

} catch (AuthenticationException $e) {
    echo "Authentication failed: {$e->getMessage()}\n";
}
```

Configuration
-------------

[](#configuration)

### Custom Base URL

[](#custom-base-url)

```
$client = new PdfenClient(
    apiToken: 'your-token',
    baseUrl: 'https://custom-domain.com'
);
```

### Custom HTTP Client Options

[](#custom-http-client-options)

```
$client = new PdfenClient(
    apiToken: 'your-token',
    httpOptions: [
        'timeout' => 120,
        'verify' => true,
        'proxy' => 'tcp://localhost:8125'
    ]
);
```

API Reference
-------------

[](#api-reference)

### User Resource

[](#user-resource)

- `$client->user()->get()` - Get current user info
- `$client->user()->credits()` - Get credits breakdown
- `$client->user()->workflows()` - List available workflows (user, organization, system)
- `$client->user()->coverTemplates()` - List cover page templates

### Convert Resource

[](#convert-resource)

- `$client->convert()` - Start conversion builder
- `->files(array $paths)` - Set files to convert
- `->workflow(int $id)` - Set workflow ID (required)
- `->coverTemplateId(int $id)` - Set cover page template ID (optional)
- `->options(array $options)` - Set conversion options
    - Options vary by workflow/conversion type
    - Common: `password`, `page_range`, `page_size`, `orientation`
    - Use `$client->workflows()->options($id)` to discover available options
    - See [API v2 Options Documentation](https://pdfen.com/api/docs/v2#options) for full list
- `->async()` - Use async mode (default)
- `->sync()` - Use sync mode (wait for completion)
- `->execute()` - Execute conversion

### Workflow Resource

[](#workflow-resource)

- `$client->workflows()->options(int $id)` - Get available options for a workflow

### Extraction Resource

[](#extraction-resource)

- `$client->extract()` - Start extraction builder
- `->files(array $paths)` - Set files to extract data from
- `->locale(string $locale)` - Set language hint (`en` or `nl`)
- `->format(string $format)` - Set output format (`json`, `csv`, `excel`, `ubl`)
- `->template(string $template)` - Set floor plan template (`room_overview`, `dimensions`, `full_detail`)
- `->invoice()` / `->invoiceDownload($path)` - Invoice extraction
- `->email()` / `->emailDownload($path)` - Email extraction
- `->form()` / `->formDownload($path)` - Form field extraction
- `->table()` / `->tableDownload($path)` - Table extraction
- `->legal()` / `->legalDownload($path)` - Legal document extraction
- `->floorPlan()` / `->floorPlanDownload($path)` - Floor plan extraction

### Execution Resource

[](#execution-resource)

- `$client->executions()->get(int $id)` - Get execution status
- `$client->executions()->download(int $id, string $path)` - Download result

Testing
-------

[](#testing)

```
# Run all tests
composer test

# Run unit tests only
composer test-unit

# Run integration tests only
composer test-integration
```

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- ext-json
- Guzzle 7.x

License
-------

[](#license)

MIT License - see [LICENSE](LICENSE) file for details.

Support
-------

[](#support)

- Documentation:
- Postman: Import the [OpenAPI spec](https://pdfen.com/api-specs/openapi-v2.yaml) directly in Postman via **Import → URL**
- Email:
- Issues:

Changelog
---------

[](#changelog)

See [CHANGELOG.md](CHANGELOG.md) for version history.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance87

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity44

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 ~92 days

Total

2

Last Release

65d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/789278794505d3624d0ae3080b6ab01a35f56ab77cd5cd2df436b212bdca1c20?d=identicon)[PDFen](/maintainers/PDFen)

---

Top Contributors

[![daan-ost](https://avatars.githubusercontent.com/u/39501528?v=4)](https://github.com/daan-ost "daan-ost (3 commits)")

---

Tags

apipdfconversionpdfen

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/pdfen-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/pdfen-php-sdk/health.svg)](https://phpackages.com/packages/pdfen-php-sdk)
```

###  Alternatives

[docraptor/docraptor

A native client library for the DocRaptor HTML to PDF/XLS service.

221.7M5](/packages/docraptor-docraptor)[pdfcrowd/pdfcrowd

A client library for the Pdfcrowd API. It lets you convert between HTML, PDF and various image formats

631.1M1](/packages/pdfcrowd-pdfcrowd)[convertkit/convertkitapi

Kit PHP SDK for the Kit API

2167.1k1](/packages/convertkit-convertkitapi)

PHPackages © 2026

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