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
'); and header(
'Content-type: application/pdf'
);
But i get always the wrong content-type.
How i can change the content type?
Thanks for help.
gloop
-- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
No comments:
Post a Comment