row-bloom / row-bloom
Table rows to pdf cards
v0.5.0
2024-01-01 16:06 UTC
Requires
- php: ^8.1
Requires (Dev)
- chrome-php/chrome: ^1.9
- illuminate/container: *
- laravel/pint: ^1.0
- mockery/mockery: ^1.6
- mpdf/mpdf: ^8.1
- pestphp/pest: ^2.0
- pestphp/pest-plugin-arch: ^2.0
- phpoffice/phpspreadsheet: ^1.28
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- spatie/browsershot: ^3.58
- symfony/var-dumper: ^6.3
- twig/twig: ^3.6
This package is auto-updated.
Last update: 2024-04-30 17:54:40 UTC
README
This package is used to generate PDFs using a table of data with one or many rows, and a template that gets applied for each row.
The goal is to allow the usage of any templating engine with any PDF generation library, by abstracting them as drivers and trying to ensure an idempotent output no matter what driver the user picks.
use RowBloom\ChromePhpRenderer\ChromePhpRenderer; use RowBloom\RowBloom\DataLoaders\FolderDataLoader; use RowBloom\RowBloom\DataLoaders\JsonDataLoader; use RowBloom\RowBloom\Interpolators\PhpInterpolator; use RowBloom\CssLength\PaperFormat; use RowBloom\RowBloom\Options; use RowBloom\RowBloom\Support; $support = (new Support) ->registerDataLoaderDriver(FolderDataLoader::NAME, FolderDataLoader::class) ->registerDataLoaderDriver(JsonDataLoader::NAME, JsonDataLoader::class) ->registerInterpolatorDriver(PhpInterpolator::NAME, PhpInterpolator::class) ->registerRendererDriver(ChromePhpRenderer::NAME, ChromePhpRenderer::class); $r = rowBloom(support: $support)->rowBloom; $r->setInterpolator('PHP')->setRenderer('Chrome') ->addTable([ ['title' => 'Title1', 'body' => 'body1'], ['title' => 'Title2', 'body' => 'body2'], ]) ->setTemplate(' <h1><?= $title ?></h1> <div><?= $body ?></div> ') ->addCss('h1 {color: red;}') ->tapOptions(function (Options $options) { $options->format = PaperFormat::_A4; $options->displayHeaderFooter = true; $options->margin = '1 in'; }) ->save(__DIR__.'/foo.pdf');
Setup
composer require row-bloom/row-bloom
Usage
Head over to the full documentation.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
License
The MIT License (MIT). Please see License File for more information.