chrisnharvey / pdfkit
HTML to PDF converter for PHP using WebKit. Uses the wkhtmltopdf C library via FFI.
Installs: 13
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/chrisnharvey/pdfkit
Requires
- php: ^7.4
- ext-ffi: *
Requires (Dev)
- phpunit/phpunit: ^9.4
This package is auto-updated.
Last update: 2025-09-20 06:44:28 UTC
README
PDFKit is a PHP package that converts HTML to PDFs using WebKit.
Uses the wkhtmltopdf C library via PHP FFI.
Note: This package is a work in progress and its API is subject to change. Use in production environments not recommended.
Requirements
- PHP 7.4 or later
- FFI extension (see Dockerfile)
- wkhtmltopdf library (see Dockerfile)
Installation
composer require chrisnharvey/pdfkit
Usage
use ChrisHarvey\PDFKit\PDFKit; use ChrisHarvey\PDFKit\ConversionFailedException; $pdfkit = new PDFKit(); // Add a page to the pdf $pdfkit->add([ 'page' => 'http://example.com' ]); $pdfkit->saveTo('example.pdf'); $pdfkit->onStageChanged(function () { echo "Moved to next stage"; }); $pdfKit->onProgressChanged(function ($percent) { echo $percent; // Print percentage }); try { $pdfkit->convert(); } catch (ConversionFailedException $e) { print_r($e->getErrors()); print_r($e->getWarnings()); }