使用TCPDF为CakePHP 2.0创建PDF Helper [英] Creating PDF Helper for CakePHP 2.0 using TCPDF

查看:75
本文介绍了使用TCPDF为CakePHP 2.0创建PDF Helper的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在为我的Cake应用程序处理PDF视图,并找到了本教程。

I'm currently working on a PDF view for my cake application and found this tutorial.

http://www.startutorial.com/articles/view/how-to-create-pdf-helper-with -tcpdf

但目前我正在为该错误消息苦苦挣扎:

But currently I'm struggling over this error message:

Notice (8): Undefined variable: pdf [APP\View\Pdfs\index.ctp, line 2]
Notice (8): Trying to get property of non-object [APP\View\Pdfs\index.ctp, line 2]
Fatal error: Call to a member function addPage() on a non-object in \app\View\Pdfs\index.ctp on line 2

任何人都可以帮帮我,我必须适应CakePHP 2.0

Can anyone help me out, what I have to adapt to CakePHP 2.0

推荐答案

对于Cake 2.1,使用以下代码:

For Cake 2.1, use this code:

<?php
    $this->Pdf->core->addPage('', 'USLETTER');
    $this->Pdf->core->setFont('helvetica', '', 12);
    $this->Pdf->core->cell(30, 0, 'Hello World');
    $this->Pdf->core->Output('example_001.pdf', 'D');
?>

这篇关于使用TCPDF为CakePHP 2.0创建PDF Helper的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆