kekos/booya-pdf

PDF response class for Booya framework

v1.0.0 2016-07-30 19:39 UTC

This package is auto-updated.

Last update: 2024-04-09 20:43:21 UTC


README

Create PDF documents with help from Booya templates with DOMPDF.

Install

You can install Booya PDF via Composer:

composer require kekos/booya-pdf

API

<?php
use Booya\Controller;
use Booya\FileTemplate;
use Booya\Pdf\PdfResponse;

class MyPdfController extends Controller {

  public function index() {
    $this->response = new PdfResponse();

    $content_template = new FileTemplate(ROOT . '/src/view/my_pdf_content');
    $this->response->addTemplate($template);
  }
}
?>

__construct($paper_size, $orientation, $public_dir)

Constructor

  • $paper_size (string, default is 'A4') - Paper size
  • $orientation (string, default is 'portrait') - Paper orientation
  • $paper_size (string, default is 'public') - Directory where Dompdf should look for public assets

setStyleSheetPath($path)

Sets the path to CSS stylesheet to use. Set $path to NULL if no stylesheet should be used.

  • $path (string) - Absolute path to stylesheet

addTemplate($template)

Adds template to current PDF document.

  • $template (\Booya\Template) - Template

render($filename)

Render the PDF to output buffer.

  • $filename (string, default is to use DOMPDF's default) - Filename without ".pdf" extension

renderToFile($filepath)

Render the PDF to file.

  • $filepath (string, mandatory) - Absolute path to store current PDF at

Bugs and improvements

Report bugs in GitHub issues or feel free to make a pull request :-)

License

MIT