0
votes

Good morning. I'm trying to generate a Pdf with Tcpdf library and bundle. I tested the basic usage of the library on a controller like this:

public function get_reporte_grupos(){           
    $pdf = new Tcpdf();
    $pdf->AddPage();
    $pdf->SetFont('times','B',16);
    $pdf->Cell(40,10,'Hello World!');
    $pdf->Output('example_001.pdf', 'I');
}

And my output is like the de binary of the pdf file:

%PDF-1.7 % 8 0 obj << /Type /Page /Parent 1 0 R /LastModified (D:20130725101953-04'30') /Resources 2 0 R /MediaBox [0.000000 0.000000 595.276000 841.890000] /CropBox [0.000000 0.000000 595.276000 841.890000] /BleedBox [0.000000 0.000000 595.276000 841.890000] /TrimBox [0.000000 0.000000 595.276000 841.890000] /ArtBox [0.000000 0.000000 595.276000 841.890000] /Contents 9 0 R /Rotate 0 /Group << /Type /Group /S /Transparency /CS /DeviceRGB >> /Annots [ 7 0 R ] /PZ 1 >> endobj 9 0 obj <> stream xSN0+[{qW(-ꩀ%^H(Uh8R().. and so on.

What I'm missing here? I don't wanna use html2pdf because the kind of files I'm generating is way too extense and I have to get control of the page break in order to do some maths. So what I'm missing here?

Thanks in advance

1

1 Answers

0
votes

Oh well, I was gonna to delete the question, but I'll answer if someone comes with the same problem. On the controller replace

$pdf->Output('example_001.pdf', 'I');

with

return Response::make($pdf->Output('example_001.pdf', 'I'), 200, array('Content-Type' => 'application/pdf'));

And you'll get your pdf file.