I use FPDF and do the processing in the controller, and then pass the
data to the view and echo it there.
pdf_controller() {
// generate PDF
$pdfout = $pdf->output();
$this->set("pdfout", $pdfout);
$this->render("pdf_controller", "pdf");
}
and pdf_controller.ctp
<?php echo $pdfout; ?>
//
I do save the PDFs in my database and have to do it this way, but I
think it's better having this logic in the controller (or a custom
class that extends the tcpdf class).
/mathias
2008/12/5 Pietrowsky, Dennis <[EMAIL PROTECTED]>:
>
> Hello everybody,
>
> I just got the Tutorial from
> http://bakery.cakephp.org/articles/view/creating-pdf-files-with-cakephp-and-tcpdf
> working, too. The header and footer are displayed correctly, but
> $tcpdf->Cell(0,14, "Hello World", 0,1,'L');
> in the view doesn't show any effect.
>
> If I put
> $this->Cell(0,14, "Hello World", 0,1,'L');
> into the header function of vendors/xtcpdf.php I get the expected cell.
>
> Any ideas about that?
>
> Thanks for your help in advance
>
> Mit freundlichen Grüßen
> alltours flugreisen gmbh
>
> Dennis Pietrowsky
> EDV-Softwareentwicklung
> Am Innenhafen 8-10
> 47059 Duisburg
> Tel.: +49 (0)2 03-36 36-708
> Fax.: +49 (0)2 03-36 36-963
> E-Mail: [EMAIL PROTECTED]
> Internet: www.alltours.de
>
> Geschäftsführer: Willi Verhuven (Vors.), Peter Wennel
> Handelsregister: Amtsgericht Duisburg, HR B 9184
>
>
>
> -----Ursprüngliche Nachricht-----
> Von: [email protected] [mailto:[EMAIL PROTECTED] Im Auftrag von
> Fernando Mendonça
> Gesendet: Dienstag, 2. Dezember 2008 12:47
> An: CakePHP
> Betreff: Re: TCPDF and Cake PHP
>
>
> Hello everybody,
>
> Thanks very much everybody helps me.
>
> I follow all steps that qwanta said and the pdf generate works! In my view I
> put:
>
> <?php
> App::import('Vendor','xtcpdf');
> $tcpdf = new XTCPDF();
> $textfont = 'freesans'; // looks better, finer, and more condensed than
> 'dejavusans'
>
> $tcpdf->SetAuthor("KBS Homes & Properties a http://kbs-properties.com");
> $tcpdf->SetAutoPageBreak( false );
> $tcpdf->setHeaderFont(array($textfont,'',20));
> $tcpdf->xheadercolor = array(150,0,0);
> $tcpdf->xheadertext = 'Test';
> $tcpdf->xfootertext = 'Copyright (c) %d KBS Homes & Properties. All rights
> reserved.';
>
>
>
> // Now you position and print your page content // example:
> $tcpdf->SetTextColor(0, 0, 0);
> $tcpdf->SetFont($textfont,'B',20);
> $tcpdf->Cell(0,14, "Hello World", 0,1,'L'); // ...
> // etc.
> // see the TCPDF examples
>
> $tcpdf->Output('filename.pdf', 'I');
>
> ?>
>
> Thanks again (specially qwanta and modfather)!!!
>
> see you!
>
> On 1 dez, 20:18, modfather <[EMAIL PROTECTED]> wrote:
>> You might try and remove "echo" from your last line of code and leave
>> it as: $tcpdf->Output('filename.pdf', 'D'); I don't know how your
>> routes are set up but you might try
>> 127.0.0.1/cake/myapp/teacher/viewpdf/1 - you are missing the action
>> from your url.
>>
>> On Dec 1, 10:34 pm, Fernando Mendonça <[EMAIL PROTECTED]> wrote:
>>
>> > Hi everybody,
>>
>> > I'm trying to generate some pdfs files with Cake PHP and TCPDF with
>> > Bakery Tutorial of this
>> > address:http://bakery.cakephp.org/articles/view/creating-pdf-files-with-cakep...
>>
>> > I did everything like this tutorial and I wrote in one of my
>> > controller (teacher_controller.php) the follow code:
>>
>> > function __view($id = null) {
>> > if (!$id) {
>> > $this->Session->setFlash(__('Invalid
>> > Teacher.', true));
>> > $this->redirect(array('action'=>'index'));
>> > }
>>
>> > $this->set('teacher', $this->Teacher->read(null,
>> > $id));
>>
>> > }
>>
>> > function viewPdf($id = null)
>> > {
>> > if (!$id)
>> > {
>> > $this->Session->setFlash('Sorry, there was no property
>> > ID submitted.');
>> > $this->redirect(array('action'=>'index'), null, true);
>> > }
>> > //Configure::write('debug',0); // Otherwise we cannot use
>> > this method while developing
>>
>> > $id = intval($id);
>>
>> > $property = $this->__view($id); // here the data is pulled
>> > from the database and set for the view
>>
>> > if (empty($property))
>> > {
>> > $this->Session->setFlash('Sorry, there is no property
>> > with the submitted ID.');
>> > $this->redirect(array('action'=>'index'), null, true);
>> > }
>>
>> > $this->layout = 'pdf'; //this will use the pdf.ctp layout
>> > $this->render();
>> > }
>>
>> > I created the view (viewPdf.ctp) too:
>>
>> > <?php
>> > App::import('Vendor','xtcpdf');
>> > $tcpdf = new XTCPDF();
>> > $textfont = 'freesans'; // looks better, finer, and more condensed
>> > than 'dejavusans'
>>
>> > $tcpdf->SetAuthor("KBS Homes & Properties
>> > athttp://kbs-properties.com"); $tcpdf->SetAutoPageBreak( false );
>> > $tcpdf->setHeaderFont(array($textfont,'',40));
>> > $tcpdf->xheadercolor = array(150,0,0); $tcpdf->xheadertext = 'KBS
>> > Homes & Properties'; $tcpdf->xfootertext = 'Copyright (c) %d KBS Homes
>> > & Properties. All rights reserved.';
>>
>> > // Now you position and print your page content // example:
>> > $tcpdf->SetTextColor(0, 0, 0);
>> > $tcpdf->SetFont($textfont,'B',20);
>> > $tcpdf->Cell(0,14, "Hello World", 0,1,'L'); // ...
>> > // etc.
>> > // see the TCPDF examples
>>
>> > echo $tcpdf->Output('filename.pdf', 'D');
>>
>> > ?>
>>
>> > But when I try to acess: 127.0.0.1/cake/myapp/teacher/1 the message
>> > "Sorry, there is no property with the submitted ID." appears. I know
>> > this message has to appears when nothing is set to $property, but I
>> > thing I'm doing this.
>>
>> > Anybody Can help me?
>>
>> > Thanks
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---