public function download() { App::uses('CakePdf', 'Plugin/CakePdf/Pdf'); $CakePdf = new CakePdf(); $CakePdf->template('teste', 'default'); $CakePdf->viewVars(array('nome' => 'Thiago')); $CakePdf->output(); $path = WWW_ROOT . DS . 'files' . DS; $path .= uniqid() . '.pdf'; if ($CakePdf->write($path)) { $this->response->file($path, array('download' => true, 'name' => 'teste_' . uniqid())); return $this->response; } }