Got the same problem. But the solution is easy. Delete the
header("Content-Type: application/pdf"); line in your layout file.
Just put this line into your controller action instead:
$this->RequestHandler->respondAs("pdf");
Works fine with CakePHP 2.x
Cheers
On Thursday, July 26, 2012 12:04:32 AM UTC+2, gloop wrote:
>
> Hello,
>
> i would like to create a pdf. Now i found this:
>
>
> http://bakery.cakephp.org/articles/kalileo/2010/06/08/creating-pdf-files-with-cakephp-and-tcpdf
>
> So i try this example:
>
> Step: 1, 2, 3 the same as the example
>
> Step 4:
>
> function viewPdf() {
> $this->layout = 'pdf'; //this will use the pdf.ctp layout
> $this->render();
> }
>
> Step 5:
>
> <?php
> App::import('Vendor','xtcpdf');
> $tcpdf = new XTCPDF();
> $textfont = 'freesans'; // looks better, finer, and more condensed than
> 'dejavusans'
>
> $tcpdf->Cell(0,14, "Hello World", 0,1,'L');
> echo $tcpdf->Output('filename.pdf', 'D');
> ?>
>
> When i open function in a browser i get a download popup and i have to
> choose how i would open the document. The standard software is "firefox".
>
> I try
>
> echo $tcpdf->Output('filename.pdf', 'D');
>
> and i see many text (like i open the pdf with firefox. I check the http
> header and see the document is opend with Content-Type: text/html;
> charset=UTF-8
>
>
> I try:
>
> In the controller $this->header('Content-type: application/pdf'); andheader(
> 'Content-type: application/pdf');
>
> But i get always the wrong content-type.
>
> How i can change the content type?
>
> Thanks for help.
> gloop
>
--
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.