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-cakephp-and-tcpdf

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 at http://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 © %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 cake-php@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to