Skip to content

davidjr82/php-pdf-generator

Repository files navigation

PHP wrapper for engines (pdflatex, pandoc) to generate PDF files

This package is a wrapper for engines to make easier generate PDF files from PHP. PDFLatex is the default engine. Excelent pandoc engine will be also provided, so more output formats can be achiueved.

Requirements

Software for the engine should be installed first. Default is pdflatex:

Faster but bigger: sudo apt-get update sudo apt-get install texlive-full poppler-utils

Slower but smaller (manually selecting packages, for example): sudo apt-get update sudo apt-get install texlive-base texlive-latex-base texlive-latex-recommended texlive-latex-extra texlive-science texlive-fonts-recommended texlive-fonts-extra texlive-lang-english texlive-lang-spanish poppler-utils

Installation

You can install the package via composer:

composer require davidjr82/php-pdf-generator

Usage

Example demo tex file:

    return (new PDFGenerator())->setTestRenderedSource()->showInBrowser('filename.pdf');
    return (new PDFGenerator())->setTestRenderedSource()->download('filename.pdf');
    return (new PDFGenerator())->setTestRenderedSource()->saveFile('filename.pdf');

Example tex file:

    $tex = file_get_contents('path/to/file.tex');

    return (new PDFGenerator())->setRenderedSource($tex)->showInBrowser('filename.pdf');
    return (new PDFGenerator())->setRenderedSource($tex)->download('filename.pdf');
    return (new PDFGenerator())->setRenderedSource($tex)->saveFile('filename.pdf');

Example Laravel users:

    $view = view('path.to.blade', $data)->render();

    return (new PDFGenerator())->setRenderedSource($view)->showInBrowser('filename.pdf');
    return (new PDFGenerator())->setRenderedSource($view)->download('filename.pdf');
    return (new PDFGenerator())->setRenderedSource($view)->saveFile('filename.pdf');

Testing

I know, I know... in the todo list.

composer test

To do list

  • Tests
  • Add pandoc library to generate PDF
  • Allow more input and output formats with pandoc

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

Inspiration / Thanks to:

License

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

About

Yet another php pdf generator package

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published