fpdf with cakephp

0

I am using the library in fpdp's cakephp, I created a private method in my controller by putting together a basic pdf and then I called this method in an action but it does not generate the pdf ..

private method:

private function montaPDF(){
    require('fdpf/fpdf.php');
    $pdf = new FPDF();
    $pdf->AddPage();
    $pdf->SetFont('Arial','B',16);
    $pdf->Cell(40,10,'Hello World!');
    $pdf->Output();
}

and returns this error on my page:

  

% PDF-1.3 3 0 obj < > endobj 40 obj < > stream x 3R 2 35W ( r Q w3T04 30PISp Z * [ (hx + (j * d 7W endstream endobj 1 0 obj & lt ; > endobj 5 0 obj

asked by anonymous 24.08.2015 / 15:33

1 answer

0

1 - Create a layout eg "pdf.ctp" in / views / layoyts

<?php
header("Content-type: application/pdf"); 
echo $content_for_layout;
?>

2 - In the controller, use the layout quoted above.

3 - In the view, make sure you use TCPDF with the correct encoding.

$pdf = new TCPDF('P', 'mm', 'A4', true, 'UTF-8', false);

Link: link

    
27.10.2015 / 20:01