PHPackages                             voquis/pdfapi - 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. [PDF &amp; Document Generation](/categories/documents)
4. /
5. voquis/pdfapi

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

voquis/pdfapi
=============

A PDF API for generating business documents

0.0.1-alpha(7y ago)00[2 PRs](https://github.com/voquis/pdfapi/pulls)MITPHPPHP ^7.2

Since May 11Pushed 4y ago1 watchersCompare

[ Source](https://github.com/voquis/pdfapi)[ Packagist](https://packagist.org/packages/voquis/pdfapi)[ Docs](https://github.com/voquis/pdfapi)[ RSS](/packages/voquis-pdfapi/feed)WikiDiscussions main Synced 2w ago

READMEChangelogDependencies (9)Versions (4)Used By (0)

[![Build Status](https://camo.githubusercontent.com/ce64ab0775647bb690ba0740e0f7a442ff1346f88414365fb5edf39eb2d8eacb/68747470733a2f2f7472617669732d63692e6f72672f766f717569732f7064666170692e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/voquis/pdfapi) [![codecov](https://camo.githubusercontent.com/2244db08564f5e767336de485be9ea66daeb72a290fbe8490a72a065189db695/68747470733a2f2f636f6465636f762e696f2f67682f766f717569732f7064666170692f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/voquis/pdfapi)

Introduction
============

[](#introduction)

A PHP API for generating business documents in PDF format.

Usage
=====

[](#usage)

Once the API is running using one of the methods below, the following endpoints are available:

- POST /invoice
- POST /purchaseOrder

Sample invoice requests
-----------------------

[](#sample-invoice-requests)

Body data should be posted as `application/json` raw content type.

```
{
  "logoHeight": 55,
  "emailTelUnderLogo": true,
  "company": {
    "name": "Example Limited",
    "number": "12345678",
    "vatNumber": "GB12345678901",
    "email": "hello@example.com",
    "telephone": "01234 567 890",
    "logoUrl": "https://example.com/logo.png",
    "address": {
      "line1": "123 House Street",
      "line2": "Townville",
      "city": "Citybourne",
      "postcode": "PO57 C0D"
    }
  },
  "invoice": {
    "ref": "INV-123",
    "summary": "For the provision of services.",
    "notes": "",
    "instructions": "Please make BACS direct credit payments to: Example Limited | Account Number: 00000000 | Sorting code: 00-00-00",
    "symbol": "&pound;",
    "net": 1234.56,
    "tax": 100.00,
    "gross": 1334.56,
    "company": {
      "name": "Customer Limited",
      "address": {
        "line1": "1a Flat Towers",
        "line2": "Low High Street",
        "city": "Uptown",
        "postcode"     : "C0D P057"
      }
    },
    "items": [
      {
        "quantity": 1,
        "description": "Provision of services relating to particulars",
        "unitPrice": 354.17,
        "taxPercent": 20,
        "net": 425
      },
      {
        "quantity": 1,
        "description": "Production of widgets conforming to specification J-21",
        "unitPrice": 354.17,
        "taxPercent": 20,
        "net": 425
      }
    ],
    "keyValuePairs": [
      {
        "key": "Tax Point",
        "value": "2019-09-02"
      },
      {
        "key": "Period",
        "value": "2019-08-01 to 2019-08-31"
      }
    ]
  }
}
```

Docker
------

[](#docker)

To run the API as a Docker container, a single http endpoint needs to be exposed, for example to `3002` on the host machine:

```
docker run -p 3002:80 voquis/pdfapi

```

To run in detached mode, add `-d` before the image name.

Development
===========

[](#development)

The API uses the [Laravel Lumen](https://lumen.laravel.com/docs) framework and makes use of [voquis/pdflib](https://github.com/voquis/pdflib), a library built on [TCPDF](https://tcpdf.org).

Developing in Docker
--------------------

[](#developing-in-docker)

First start a development container in detached mode and mount the source code as a volume:

```
docker run \
-d \
--name pdfapi_dev \
--hostname pdfapi_dev \
-v /local/path/to/source:/pdfapi \
-p 3000:80 \
-p 3001:9000 \
-w /pdfapi \
php:7.3.5-apache

```

To use the current directory instead of specifying the full local path, use `-v `pwd`:/pdfapi `. If using docker for windows, change paths to `//c/path/to/source://pdfapi`. Then connect to the running container in interactive mode (`-i`) and to the TTY (-t). Note that if using git for Windows, the prefix `winpty` may be required. If using CentOS/RHEL or other SELinux enabled distros, use `:Z` (exclusive access to this container) or `:z` (shared with other containers) at the end of the volume mounts to set appropriate permissions, i.e. `-v /local/path/to/source:/pdfapi:Z`. See this [StackOverflow question/answer](https://stackoverflow.com/questions/35218194/what-is-z-flag-in-docker-containers-volumes-from-option) for further details.

```
docker exec -it pdfapi_dev bash

```

To disconnect and leave a container running use `Ctrl+P` then `Ctrl+Q`.

### Install and enable dependencies

[](#install-and-enable-dependencies)

Note that the base Docker PHP image has a utility `docker-php-ext-install` for installing and enabling PHP extensions. The `gd` extension is used for parsing image logos in the header. The `xsl` extension is used during tests and is not required for production (see `Dockerfile` for production optimisation).

```
apt-get update
apt-get install -y libpng-dev vim git unzip libxslt1-dev
docker-php-ext-install gd xsl

```

### Install tools

[](#install-tools)

Install Xdebug and add config file. The xdebug extension is required for producing unit test coverage reports. The `xdebug.remote_enable` and `xdebug.remote_autostart` options are only required if remote debugging will be used (port `9000`).

```
pecl install xdebug
echo "zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_autostart=1" > /usr/local/etc/php/conf.d/xdebug.ini

```

### Increase memory limit

[](#increase-memory-limit)

Static code analysis ([phpstan](https://github.com/phpstan/phpstan)) may hit default PHP memory limits, to increase this, run the following. Note that this creates a new `ini` config file.

```
echo "memory_limit=512M" > /usr/local/etc/php/conf.d/memory.ini

```

### Install and run composer

[](#install-and-run-composer)

Acquire the latest version of composer with `curl` and output (`-o`) to system-wide binary path, following any redirects (`-L`). Update permissions to allow executing (`+x`). Instruct composer to check out from git with `--prefer-source`, this will allow development of any vendor libraries if required.

```
curl -Lo /usr/local/bin/composer https://getcomposer.org/composer.phar
chmod +x /usr/local/bin/composer
composer install --prefer-source

```

### Configure writeable directories

[](#configure-writeable-directories)

Give apache permission to write to `storage` and sub-directories.

```
chown -R www-data storage

```

### Configure Apache

[](#configure-apache)

Enable the `rewrite` apache2 module, then update the configs to change from default webroot directory to location of project files in mounted volume (`/pdflib`).

```
a2enmod rewrite
sed -ri -e 's!/var/www/html!/pdfapi/public!g' /etc/apache2/sites-available/*.conf
sed -ri -e 's!/var/www/!/pdfapi!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
service apache2 restart

```

Note that restarting apache2 will terminate the container so will need to run `docker container start pdfapi_dev` and then reconnect.

Contributing
============

[](#contributing)

Contributions are welcome in the form of issue reporting and pull-requests, please fork the repository with any proposed changes. Please ensure 100% unit test code coverage is maintained and that tests are run locally with `composer test` before pushing your changes. To generate unit test coverage report, run `composer phpunit-html`. These commands are defined in `composer.json` under `scripts`.

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

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

Unknown

Total

1

Last Release

2606d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/50292267?v=4)[Voquis](/maintainers/voquis)[@voquis](https://github.com/voquis)

---

Top Contributors

[![danial-k](https://avatars.githubusercontent.com/u/31406378?v=4)](https://github.com/danial-k "danial-k (8 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/voquis-pdfapi/health.svg)

```
[![Health](https://phpackages.com/badges/voquis-pdfapi/health.svg)](https://phpackages.com/packages/voquis-pdfapi)
```

###  Alternatives

[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k12](/packages/tempest-framework)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45344.0k1](/packages/pressbooks-pressbooks)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[lion/bundle

Lion-framework configuration and initialization package

122.3k3](/packages/lion-bundle)

PHPackages © 2026

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