-
Book Overview & Buying
-
Table Of Contents
CakePHP 2 Application Cookbook - Third Edition
By :
There comes a time when you'll want to create a PDF document in many applications. In this recipe, we'll look at how to output some content in a PDF document.
For this recipe, we'll use a plugin called CakePdf, which can be found at https://github.com/ceeram/CakePdf.
The contents of this plugin should be added to app/Plugin/CakePdf/ and loaded by the application. To do so, add the following code to your bootstrap.php file located in app/Config/:
CakePlugin::load('CakePdf', array(
'bootstrap' => true,
'routes' => true
));Then, we need a controller to generate a PDF document. Create a file named ReportsController.php in app/Controller/, and introduce the following content:
<?php
App::uses('AppController', 'Controller');
class ReportsController extends AppController {
}Then, we'll set up some configuration options for the plugin. The most important of all is the PDF engine we want to use, as the plugin provides a few. For this example, we'll use dompdf...
Change the font size
Change margin width
Change background colour