2017 © Pedro Peláez
 

cakephp-plugin cakephp-wkhtmltopdf

CakePHP 2.x View and Component for WkHtmlToPdf

image

milanzor/cakephp-wkhtmltopdf

CakePHP 2.x View and Component for WkHtmlToPdf

  • Monday, March 26, 2018
  • by Milanzor
  • Repository
  • 1 Watchers
  • 1 Stars
  • 22 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 5 % Grown

The README.md

Packagist license, (*1)

WkHtmlToPdf in CakePHP 2

Provides a View and a Component for generating PDF's through view's in Cake 2. Uses WkHtmlToPdf., (*2)

Currently only supports WkHtmlToPdf AMD64!, (*3)

How to use

  • composer require milanzor/cakephp-wkhtmltopdf
  • Load the plugin in Cake
  • Enable parsing of extension pdf in your routes: Router::parseExtensions('pdf');
  • Enable the RequestHandler to handle .pdf requests using the following snippet in your (App)Controller:

php public $components = [ 'RequestHandler' => [ 'viewClassMap' => [ 'pdf' => 'CakephpWkhtmltopdf.Pdf', ], ], ];, (*4)

Now when you call a page, e.g. http://yoursite.local/invoices/view.pdf, the RequestHandler will offhand the request to this plugin's PdfView. Resulting in your view + layout files to be rendering into a PDF., (*5)

Available options

In your Controller methods, you can set the following viewVars:, (*6)

  • To force a file download: $this->set('_download', 'filename-without-.pdf-extension');
  • To stream the pdf to the browser: $this->set('_stream', true);
  • Save the file: $this->set('_save', '/full/path/to/file.pdf');
  • Additional WkHtmlToPdf options can be passed to the WkHtmlToPdf PHP instance using: $this->set('WkHtmlToPdf_options', []); For these options, see https://github.com/mikehaertl/phpwkhtmltopdf

Questions?

Feel free to make an issue or PR!, (*7)

The Versions

26/03 2018

dev-master

9999999-dev

CakePHP 2.x View and Component for WkHtmlToPdf

  Sources   Download

MIT

The Requires

 

by Milan van As

26/03 2018

1.0.2

1.0.2.0

CakePHP 2.x View and Component for WkHtmlToPdf

  Sources   Download

MIT

The Requires

 

by Milan van As

23/03 2018

1.0.1

1.0.1.0

CakePHP 2.x View and Component for WkHtmlToPdf

  Sources   Download

MIT

The Requires

 

by Milan van As

23/03 2018

1.0.0

1.0.0.0

CakePHP 2.x View and Component for WkHtmlToPdf

  Sources   Download

MIT

The Requires

 

by Milan van As