dev-master
9999999-dev https://github.com/gianksp/cakephp-dompdfDompdf Plugin for CakePHP
MIT
The Requires
- php >=5.3.0
- dompdf/dompdf ^0.6
The Development Requires
cakephp pdf
Wallogit.com
2017 © Pedro Peláez
Dompdf Plugin for CakePHP
This plugin for the CakePHP Framework allows you to use the dompdf HTML to PDF converter to easily create PDF documents. It's tightly integrated with the CakePHP view renderer., (*1)
composer require gianksp/cakephp-dompdf:dev-master
Download dompdf 0.6 and move the content of the archive to Plugin/Dompdf/Vendor/dompdf., (*2)
Please create a cache folder for dompdf called dompdf in APP/tmp/cache and change the permissions to 777., (*3)
Because of the tight integration between this plugin and CakePHP, there's only a few things you have to do to get started., (*4)
CakePlugin::load('Dompdf', array('bootstrap' => true)); to APP/Config/bootstrap.php.Router::parseExtensions('pdf'); to APP/Config/routes.php. If you already use Router::parseExtensions in your project, simply add 'pdf' to the list.public $components = array('RequestHandler'); to APP/Controller/AppController.php.Copy the APP/Plugin/Dompdf/Config/dompdf.php to APP/Config if you want to change any of the default configuration., (*5)
You'll need to create the default layout for your PDF documents by creating a file named default.ctp in APP/View/Layouts/pdf., (*6)
For each action that should return a PDF, simply create a pdf folder in the folder where the views for the controller reside and create a file with the name of the action inside the pdf folder., (*7)
For example, if your controller is named DocumentsController and the action is named view, you need to create the view.ctp file in APP/View/Documents/pdf., (*8)
There are a few view variables that you can use to change the behaviour of the view., (*9)
download Set to true to set a Content-Disposition header. This is ideal for file downloads.name The filename that will be sent to the user, specified with the extension.paperOrientation The paper orientation. Must be either 'landscape' or 'portrait'.paperSize The paper size. Acceptable values include 'letter', 'legal', 'a4', etc. See CPDF_Adapter::$PAPER_SIZES.Example:, (*10)
public function view($id)
{
// ...
$params = array(
'download' => false,
'name' => 'example.pdf',
'paperOrientation' => 'portrait',
'paperSize' => 'legal'
);
$this->set($params);
}
To access any action as a PDF, all you have to do is point your browser to the URL associated with the action in question and add '.pdf' at the end just like you would do for JSON or XML., (*11)
For example:, (*12)
http://example.com/documents/view/100.pdf
Dompdf Plugin for CakePHP
MIT
cakephp pdf