typesetterio/typesetter
| Install | |
|---|---|
composer require typesetterio/typesetter |
|
| Latest Version: | 0.11.1 |
| PHP: | ^8.3 |
| License: | MIT |
| Last Updated: | Oct 8, 2026 |
| Links: | GitHub · Packagist |
Typesetter
This is the Typesetter main service. This can be used in your own projects directly if you want. You probably want to head over to typesetter-cli though.
Install
This requires PHP 8.3 or above.
composer require typesetterio/typesetter
Usage
Build a Config from an array of options, then pass it to Typesetter::generate() to get a PDF binary back from MPDF.
Example:
$config = new \Typesetterio\Typesetter\Config([
'title' => 'Benjamin Button',
'author' => 'F. Scott Fitzgerald',
'theme' => 'bb',
'toc-enabled' => true,
'toc-links' => true,
'toc-header' => 'Table of Contents',
'footer' => '{PAGENO}',
'markdown-extensions' => ['md', 'markdown'],
'observers' => [
new \Typesetterio\Typesetter\Observers\DefaultMarkdownConfiguration(),
new \Typesetterio\Typesetter\Observers\FirstElementInChapterCSSClass(),
new \Typesetterio\Typesetter\Observers\BreakToPageBreak(),
new \Typesetterio\Typesetter\Observers\Credits(),
],
]);
$service = new \Typesetterio\Typesetter\Typesetter();
$pdfContent = $service->generate($config);
file_put_contents('my-pdf.pdf', $pdfContent);
To learn more, please check out the documentation. This details configuration, customization, themes and cover generation, observers, listeners and more.
Demo
The demo/ directory contains a runnable example used for manual smoke testing. It includes a small theme, three Markdown chapters that exercise each bundled observer, and demo/run.php, which generates a PDF at demo/output.pdf (gitignored). Run it from the project root with php demo/run.php.
Development
Requires PHP 8.5, Composer, Docker, and act. On macOS, brew install php composer act.
Run make to list the available targets.
Changelog
See CHANGELOG.md.
Credits
This was heavily influenced by the Ibis project but is a complete rewrite.
This package stands on the shoulders of giants like MPDF and the League Commonmark library.
Aaron Saray is the primary author and maintainer.
Related Packages
PHP package to read metadata and extract covers from eBooks, comics and audioboo...
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| 0.11.1 | ^8.3 | ^10.12| | MIT | |
| 0.11.0 | ^8.3 | ^10.12| | MIT | |
| 0.10.1 | ^8.2 | ^10.12| | MIT | |
| 0.10.0 | ^8.1 | ^10.12| | MIT | |
| 0.9.1 | ^8.1 | ^10.12 | MIT | |
| 0.9.0 | ^8.1 | ^10.12 | MIT | |
| 0.8.3 | ^8.1 | ^10.12 | MIT | |
| 0.8.2 | ^8.1 | ^10.12 | MIT | |
| 0.8.1 | ^8.1 | ^10.12 | MIT | |
| 0.8.0 | ^8.1 | ^10.12 | MIT | |
| 0.7.0 | ^8.1 | ^10.12 | MIT | |
| 0.6.2 | ^8.1 | ^10.12 | MIT | |
| 0.6.1 | ^8.1 | ^10.12 | MIT | |
| 0.6.0 | ^8.1 | ^10.12 | MIT | |
| 0.5.0 | ^8.1 | ^10.12 | MIT | |
| 0.4.0 | ^8.1 | ^10.12 | MIT | |
| 0.3.0 | ^8.1 | ^10.12 | MIT | |
| 0.2.0 | ^8.1 | ^10.12 | MIT | |
| 0.1.0 | ^8.1 | ^10.12 | MIT |