PHPackages                             asyncphp/paper - 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. asyncphp/paper

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

asyncphp/paper
==============

Hassle-free HTML to PDF conversion abstraction library

0.1.0(9y ago)1961.2k3[1 issues](https://github.com/asyncphp/paper/issues)MITPHPPHP ^5.6|^7.0CI failing

Since Jan 19Pushed 6y ago8 watchersCompare

[ Source](https://github.com/asyncphp/paper)[ Packagist](https://packagist.org/packages/asyncphp/paper)[ RSS](/packages/asyncphp-paper/feed)WikiDiscussions develop Synced 2d ago

READMEChangelog (1)Dependencies (9)Versions (3)Used By (0)

Paper
=====

[](#paper)

Hassle-free HTML to PDF conversion abstraction library.

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

[](#installation)

```
composer require asyncphp/paper

```

For best results, you should also install [Prince](https://www.princexml.com) and [WKHTMLtoDPF](http://wkhtmltopdf.org). To run the tests, you'll also need to install [diff-pdf](https://github.com/vslavik/diff-pdf). If you don't have the latter installed, you'll not be able to run the tests. If you don't have the former installed, the relevant tests will be skipped, and drivers unusable.

Usage
-----

[](#usage)

You can use any of the drivers directly:

```
use AsyncInterop\Loop;
use AsyncPHP\Paper\Driver\DomDriver;
use AsyncPHP\Paper\Runner\AmpRunner;

Loop::execute(Amp\wrap(function() use ($sample) {
    $driver = new DomDriver();
    $runner = new AmpRunner();

    $promise = $driver
        ->html($sample)
        ->size("A4")
        ->orientation("portrait")
        ->dpi(300)
        ->render($runner);

    $results = yield $promise;
}));
```

However, it's must easier to use the factory, to create pre-configured drivers:

```
use AsyncPHP\Paper\Factory;

$config = [
    "driver" => "dom",

    "dom" => [
        "options" => [
            "fontDir" => __DIR__ . "/fonts",
            // https://github.com/dompdf/dompdf/blob/master/src/Options.php
        ],
    ],

    "prince" => [
        "binary" => "/opt/prince/bin/prince",
        "tempPath" => __DIR__,
        "options" => [
            "--no-compress",
            "--http-timeout" => 10,
            // https://www.princexml.com/doc/command-line/#command-line
        ],
    ],

    "webkit" => [
        "binary" => "/usr/local/bin/wkhtmltopdf",
        "tempPath" => __DIR__,
        "options" => [
            "--grayscale",
            "--javascript-delay" => 500,
            // http://wkhtmltopdf.org/usage/wkhtmltopdf.txt
        ],
    ],

    "runner" => "amp",
];

$factory = new Factory();
$driver = $factory->createDriver($config);
$runner = $factory->createRunner($config);

yield $driver->html($sample)->render($runner);
```

Paper takes an async-first approach. Operations, like rendering PDF files, are particularly suited to parallel processing architecture. You may be stuck rending PDF files in a synchronous architecture, in which case you can use the `SyncDriver` decorator:

```
$driver = new SyncDriver(new DomDriver());

// ...or with the factory

$driver = $factory->createDriver([
    "driver" => "dom",
    "sync" => true,
]);
```

Drivers
-------

[](#drivers)

Here's a list of the drivers to currently support:

### [DOMPDF](http://dompdf.github.io)

[](#dompdf)

- Requires command-line utilities: **no**
- Supports modern CSS: **no**
- Supports modern JS: **no**
- Produces vector files: **yes**
- Open + free: **yes**

### [WKHTMLtoDPF](http://wkhtmltopdf.org)

[](#wkhtmltodpf)

- Requires command-line utilities: **yes**
- Supports modern CSS: **yes**
- Supports modern JS: **yes**
- Produces vector files: **yes**
- Open + free: **yes**

### [Prince](https://www.princexml.com)

[](#prince)

- Requires command-line utilities: **yes**
- Supports modern CSS: **yes**
- Supports modern JS: **yes**
- Produces vector files: **yes**
- Open + free: **no**

Runners
-------

[](#runners)

Paper supports [Amp](https://github.com/amphp) and [React](https://github.com/reactphp), to package and run the async code. You have to install one of the following library groups:

### [Amp](examples/async-amp-dom.php)

[](#amp)

```
composer require amphp/loop
composer require amphp/parallel
composer require async-interop/event-loop

```

### [React](examples/async-react-webkit.php)

[](#react)

```
composer require react/event-loop
composer require react/child-process
composer require jeremeamia/superclosure

```

Take a look at the [examples](examples) folder to find out more about using the async drivers.

Roadmap
-------

[](#roadmap)

- Setters for default margin
- Setters for header HTML
- Setters for footer HTML
- More drivers (especially [DocRaptor](https://docraptor.com) – a SaaS version of Prince)

Versioning
----------

[](#versioning)

This library follows [Semver](http://semver.org). According to Semver, you will be able to upgrade to any minor or patch version of this library without any breaking changes to the public API. Semver also requires that we clearly define the public API for this library.

All methods, with `public` visibility, are part of the public API. All other methods are not part of the public API. Where possible, we'll try to keep `protected` methods backwards-compatible in minor/patch versions, but if you're overriding methods then please test your work before upgrading.

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity49

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

3451d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/00089084814b5b79cd35b9f501bcc48d74c5afb2cb4703562a82e081f31c843c?d=identicon)[assertchris](/maintainers/assertchris)

---

Top Contributors

[![assertchris](https://avatars.githubusercontent.com/u/200609?v=4)](https://github.com/assertchris "assertchris (6 commits)")

---

Tags

asyncconversionhtmlpdf

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/asyncphp-paper/health.svg)

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

###  Alternatives

[tarfin-labs/easy-pdf

Makes pdf processing easy.

1719.9k](/packages/tarfin-labs-easy-pdf)

PHPackages © 2026

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