Giter Club home page Giter Club logo

Row bloom

Latest Version on Packagist Pest action Pint action Total Downloads

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.

illustration

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.

class diagram

License

The MIT License (MIT). Please see License File for more information.

Row bloom's Projects

app icon app

Use Row bloom in Web and CLI modes

browsershot-renderer icon browsershot-renderer

Row bloom driver: relies on Node.js Puppeteer and Chrome binary to generates PDFs from HTMLs. [READONLY]

css-length icon css-length

Value objects to manipulate CSS length and ensure valid values in your PHP code. [READONLY]

mpdf-renderer icon mpdf-renderer

Row bloom driver: relies on mPDF library to generates PDFs from HTMLs. [READONLY]

row-bloom icon row-bloom

Powerful and extensible library to render tabular data into templates and generate PDFs

twig-interpolator icon twig-interpolator

Row bloom driver: Add support of Twig templates to generate HTML. [READONLY]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.