Reputation: 7930
I use html2pdf
, which is based on TCPDF
, in CakePhp to render Views
in PDF
.
However, sometimes the generation hangs, I mean the browser freezes and never receives data.
There is a way to debug such a behavior? In apache
logs I do not see any kind of error...
$this->set(compact('quotation','company','user'));
$view = new View(null, false);
$view->set(compact('quotation','company','user'));
$view->viewPath = 'Quotations';
$view->layout = 'preventivo';
if ($quotation['Quotation']['quotation_type'] == SERVICE)
{
$content = $view->render('print_s_template');
$this->set(compact('content'));
$this->response->type('pdf');
$this->render('print');
the print.ctp
has
App::import('Vendor', 'HTML2PDF', array('file' => 'html2pdf'.DS.'html2pdf.class.php'));
$html2pdf = new HTML2PDF('P','A4','it');
$html2pdf->WriteHTML($content);
$html2pdf->Output('exemple.pdf');
and the html
is in print_s_template.ctp
.
Upvotes: 1
Views: 1258
Reputation: 7930
I found a solution myself. The problem is that I forgot to pass some variables to the View $view
. And I suppose cake throw an error which, next, html2pdf
cannot "render".
So: double check that all the variables in the view do exist!
Upvotes: 2