You could put the formatting code in a view and apply the view in
order to create the PDF. That should work whether you're saving the
file or pushing it out to the browser.

For instance, using the (modified) CsvHelper[1] (formats and pushes
out CSV files) I have the following:

MembersController:
public function admin_csv()
{
        $this->set('data', $this->Member->getMembershipDump());
        $this->set('filename', 'members_'.date('Y-m-d').'.csv');
        $this->set('binary_fields', array('dlr', 'dtr', 'prd'));

        Configure::write('debug', 0);
        $this->layout = 'ajax';
        $this->viewPath = 'elements';
        $this->render('csv_dump');
}

csv_dump.ctp:

if (isset($filename)) $csv->setFilename($filename);
$csv->clean_output = true;

/* changes binary fields to 'yes' or 'no'
 */
if (isset($binary_fields)) $csv->convert_binaries = $binary_fields;
$csv->addGrid($data);
echo $csv->render();

Maybe you could do something like that for your PDF files.

[1] http://bakery.cakephp.org/articles/view/csv-helper-php5


On Thu, Mar 19, 2009 at 4:09 AM, Thomas Bensler <[email protected]> wrote:
>
> Hi there,
>
> I have some code formatting an user object as a human readable string.
> It was put into an UserHelper class as it is used in different views.
> Now I need that functionality in my UserController to put that string
> into an PDF file (using fpdf) . Trying to utilize my helper class for
> that I realized that it is not possible (pls ;) correct me if I am
> wrong).
>
> I took a look into Sessions(Helper|Component) and saw that both
> delegate to CakeSession. Cloning that pattern seems to be a little too
> big for my little formatting method.
>
> Any other idea how to deal with my "problem"?
>
> TIA, Thomas.
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to