Bonjour,
je cherche à générer un pdf sous cakephp 2 et Html2pdf,
en suivant ce topic mon pdf en bien générer (je génère bien le"Salut" en pdf).
Maintenant quant je modifie mon code pour éditer mon catalogue ça plante (Error: An Internal Error Has Occurred.),
pourvez vous m'aider? merci.
mon controleur:
public function exportpdf(){
//pour éviter les outputs du debug de cake
Configure::write('debug',0);
//la solution depuis cakephp 2
$this->response->type('pdf');
$this->paginate = array(
'order' => array('post.id' => 'asc'),
'limit' => 2
);
$d = $this->paginate('Post');
$this->set('posts',$d);
$this->layout='pdf';
}
ma view:
<?php ob_start(); ?>
<h3>Trie</h3>
<?php foreach ($posts as $k => $v):; ?>
// ..........
<?php endforeach ?>
<?php $content = ob_get_contents(); ?>
<?php
//$content = '<page>SALUT</page>';
App::import('Vendor', 'html2pdf/html2pdf');
$pdf = new HTML2PDF('P', 'A4', 'fr');
$pdf->pdf->SetDisplayMode('fullpage');
$pdf->writeHTML($content);
$pdf->Output('fichier.pdf');
?>