public function __construct(Request $request = null, Response $response = null, EventManager $eventManager = null, array $viewOptions = [])
{
$this->_passedVars[] = 'pdfConfig';
parent::__construct($request, $response, $eventManager, $viewOptions);
$this->pdfConfig = array_merge((array) Configure::read('CakePdf'), (array) $this->pdfConfig);
$response->type('pdf');
if (isset($viewOptions['name']) && $viewOptions['name'] == 'Error') {
$this->subDir = null;
$this->layoutPath = null;
$response->type('html');
return;
}
if (!$this->pdfConfig) {
throw new Exception(__d('cakepdf', 'Controller attribute $pdfConfig is not correct or missing'));
}
$this->renderer($this->pdfConfig);
}