{"id":37005666,"url":"https://github.com/asyncphp/paper","last_synced_at":"2026-01-14T00:40:52.816Z","repository":{"id":56950025,"uuid":"78729319","full_name":"asyncphp/paper","owner":"asyncphp","description":"Hassle-free HTML to PDF conversion abstraction library.","archived":false,"fork":false,"pushed_at":"2020-06-18T16:25:29.000Z","size":89,"stargazers_count":195,"open_issues_count":1,"forks_count":3,"subscribers_count":10,"default_branch":"develop","last_synced_at":"2024-04-22T19:43:11.380Z","etag":null,"topics":["async","conversion","html","pdf"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/asyncphp.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":"code-of-conduct.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-12T09:35:02.000Z","updated_at":"2024-03-21T19:36:35.000Z","dependencies_parsed_at":"2022-08-21T09:20:23.841Z","dependency_job_id":null,"html_url":"https://github.com/asyncphp/paper","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/asyncphp/paper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asyncphp%2Fpaper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asyncphp%2Fpaper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asyncphp%2Fpaper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asyncphp%2Fpaper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asyncphp","download_url":"https://codeload.github.com/asyncphp/paper/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asyncphp%2Fpaper/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28406520,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T21:51:37.118Z","status":"ssl_error","status_checked_at":"2026-01-13T21:45:14.585Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async","conversion","html","pdf"],"created_at":"2026-01-14T00:40:52.211Z","updated_at":"2026-01-14T00:40:52.798Z","avatar_url":"https://github.com/asyncphp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Paper\n\nHassle-free HTML to PDF conversion abstraction library.\n\n## Installation\n\n```\ncomposer require asyncphp/paper\n```\n\nFor 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.\n\n## Usage\n\nYou can use any of the drivers directly:\n\n```php\nuse AsyncInterop\\Loop;\nuse AsyncPHP\\Paper\\Driver\\DomDriver;\nuse AsyncPHP\\Paper\\Runner\\AmpRunner;\n\nLoop::execute(Amp\\wrap(function() use ($sample) {\n    $driver = new DomDriver();\n    $runner = new AmpRunner();\n\n    $promise = $driver\n        -\u003ehtml($sample)\n        -\u003esize(\"A4\")\n        -\u003eorientation(\"portrait\")\n        -\u003edpi(300)\n        -\u003erender($runner);\n\n    $results = yield $promise;\n}));\n```\n\nHowever, it's must easier to use the factory, to create pre-configured drivers:\n\n```php\nuse AsyncPHP\\Paper\\Factory;\n\n$config = [\n    \"driver\" =\u003e \"dom\",\n\n    \"dom\" =\u003e [\n        \"options\" =\u003e [\n            \"fontDir\" =\u003e __DIR__ . \"/fonts\",\n            // https://github.com/dompdf/dompdf/blob/master/src/Options.php\n        ],\n    ],\n\n    \"prince\" =\u003e [\n        \"binary\" =\u003e \"/opt/prince/bin/prince\",\n        \"tempPath\" =\u003e __DIR__,\n        \"options\" =\u003e [\n            \"--no-compress\",\n            \"--http-timeout\" =\u003e 10,\n            // https://www.princexml.com/doc/command-line/#command-line\n        ],\n    ],\n\n    \"webkit\" =\u003e [\n        \"binary\" =\u003e \"/usr/local/bin/wkhtmltopdf\",\n        \"tempPath\" =\u003e __DIR__,\n        \"options\" =\u003e [\n            \"--grayscale\",\n            \"--javascript-delay\" =\u003e 500,\n            // http://wkhtmltopdf.org/usage/wkhtmltopdf.txt\n        ],\n    ],\n\n    \"runner\" =\u003e \"amp\",\n];\n\n$factory = new Factory();\n$driver = $factory-\u003ecreateDriver($config);\n$runner = $factory-\u003ecreateRunner($config);\n\nyield $driver-\u003ehtml($sample)-\u003erender($runner);\n```\n\nPaper 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:\n\n```php\n$driver = new SyncDriver(new DomDriver());\n\n// ...or with the factory\n\n$driver = $factory-\u003ecreateDriver([\n    \"driver\" =\u003e \"dom\",\n    \"sync\" =\u003e true,\n]);\n```\n\n## Drivers\n\nHere's a list of the drivers to currently support:\n\n### [DOMPDF](http://dompdf.github.io)\n\n* Requires command-line utilities: **no**\n* Supports modern CSS: **no**\n* Supports modern JS: **no**\n* Produces vector files: **yes**\n* Open + free: **yes**\n\n### [WKHTMLtoDPF](http://wkhtmltopdf.org)\n\n* Requires command-line utilities: **yes**\n* Supports modern CSS: **yes**\n* Supports modern JS: **yes**\n* Produces vector files: **yes**\n* Open + free: **yes**\n\n### [Prince](https://www.princexml.com)\n\n* Requires command-line utilities: **yes**\n* Supports modern CSS: **yes**\n* Supports modern JS: **yes**\n* Produces vector files: **yes**\n* Open + free: **no**\n\n## Runners\n\nPaper 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:\n\n### [Amp](examples/async-amp-dom.php)\n\n```\ncomposer require amphp/loop\ncomposer require amphp/parallel\ncomposer require async-interop/event-loop\n```\n\n### [React](examples/async-react-webkit.php)\n\n```\ncomposer require react/event-loop\ncomposer require react/child-process\ncomposer require jeremeamia/superclosure\n```\n\nTake a look at the [examples](examples) folder to find out more about using the async drivers.\n\n## Roadmap\n\n* Setters for default margin\n* Setters for header HTML\n* Setters for footer HTML\n* More drivers (especially [DocRaptor](https://docraptor.com) – a SaaS version of Prince)\n\n## Versioning\n\nThis 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.\n\nAll 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.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasyncphp%2Fpaper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasyncphp%2Fpaper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasyncphp%2Fpaper/lists"}