首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用TCPDF为CakePHP 2.0创建PDF Helper

使用TCPDF为CakePHP 2.0创建PDF Helper
EN

Stack Overflow用户
提问于 2012-01-04 22:07:22
回答 2查看 3.4K关注 0票数 1

我目前正在为我的蛋糕应用程序开发一个PDF视图,并找到了这个教程。

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

但目前我正在为这个错误消息而苦苦挣扎:

代码语言:javascript
复制
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吗?

EN

回答 2

Stack Overflow用户

发布于 2012-05-18 02:04:52

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

代码语言:javascript
复制
<?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');
?>
票数 2
EN

Stack Overflow用户

发布于 2015-03-18 12:07:41

当我使用"$this-> pdf ->core->Output('example_001.pdf','D');“pdf文件下载正常。但是当我使用"$this->Pdf->core->Output('example_001.pdf','I');“在屏幕上显示时,我看到:

%PDF-1.7%pdf 7 0 obj << /Type /Page /Parent 1 0 R /LastModified (D:20150318050138+01'00') /Resources 2 0 R /MediaBox (D:20150318050138+01‘00’) /CropBox 2 0 R/LastModified(D:20150318050138+01‘00’)/Resources 2 0 R/MediaBox 0.000000 0.000000 612.000000 792.000000 /CropBox 0.000000 0.000000 612.000000 792.000000 /BleedBox 0.000000 612.000000 792.000000 /TrimBox 0.000000 0.000000 612.000000 792.000000 /ArtBox 0.000000 0.000000 612.000000 792.000000 /Contents 8 0 R /Rotate 0 /Group (D: 0.000000 +01‘00’)����2 0 R 0.000000 0.000000<< /Type /Group /S /Transparency /CS /DeviceRGB >> /Annots 6 0 R /PZ 1 >> endobj 8 0 obj <> stream x��SMo�0��W�#�棁�&Nl��I�e�T��2�I���ܢvCtZ�Ȋ��9/֋�f,��$��zK�#�glb�%���2�=,]��t�uB\�G���#S����l��gO�:3��"*.~��Zr������^�UW���1�s�W�n��]�ϴ�J@�D���2��+�"ux����fsl!���t{��l3lH��'�-�����u�kO> endobj 3 0 obj <> endobj 5 0 obj <> endobj 4 0 obj << /Type /XObject/Subtype /Form /FormType 1 /Filter /FlateDecode /BBox 0.000000 0.000000 612.000000 28.350000 /Matrix 1 0 1 0 0 /Resources << /ProcSet /PDF /Text /ImageB /ImageC /ImageI /Font << /F2 5 0 R /F1 3 0 R 161 stream x >> w?>> b /Length & >> z�vh�|�>ҿ�T�B8`���Z�3:���d��Q�:��|K^�2�z�Fp0�M7o���j���D��7*�{�ѯP��r��o�sV�T�kqϛ����<< /ProcSet /PDF /Text /ImageB /ImageC /ImageI /Font << /F1 3 0 R /F2 5 0 R >> /XObject << /XT4 4 0 R >> >> endobj 6 0 obj <> //XObject<>>> endobj 6 0 obj <>/I>> endobj 9 0 obj << /Producer ( TCPDF 6.2.6 (tcpdf.org)) /CreationDate (D:20150318050138+01'00') /ModDate (D:20150318050138+01'00') /Trapped /False >> endobj 10 0 obj << /Type /Metadata /Subtype /XML /Length 4223 >>流应用/pdf 2015-03-18T05:01:38+01:00��2015-03-18T05:01:38+01:00 2015-03-18T05:01:38+01:00��TCPDF 6.2.6 (tcpdf.org) uuid:45f4b8fd-7424-3ef2-034a-a956c4a4d4ec uuid:45f4b8fd-7424-3ef2-034a-a956c4a4d4ec http://ns.adobe.com/pdf/1.3/ pdf Adobe PDF架构http://ns.adobe.com/xap/1.0/mm/ xmpMM XMP媒体管理架构特定文档化身的基于UUID的内部标识符InstanceID URI aiim.org/pdfa/ns/ ID / pdfaid PDF/A ID架构PDF的内部部分/A标准件整数PDF内部修正/A标准amd文本内部一致性PDF/A标准符合性文本endstream endobj 11 0 obj << /Type /Catalog /Version /1.7 /Pages 1 0 R /Names << >> /ViewerPreferences << /Direction /L2R >> /PageLayout /SinglePage /PageMode /UseNone /OpenAction 7 0 R /FitH null /Metadata 10 0 R >> endobj xref 0 12 0000000000 65535 f 0000000832 00000 n 0000001547 00000 n 0000000891 00000 n 0000001108 00000 n 0000000997 00000 n 0000001672 00000 n 0000000015 00000 n 0000000483 00000 n 0000001943 00000 n 0000002140 00000 n 0000006446 00000 n尾部<< /Size 12 /Root 11 0 R /Info 9 0 R /ID <45f4b8fd74243ef2034aa956c4a4d4ec> <45f4b8fd74243ef2034aa956c4a4d4ec> >> startxref 6655%EOF

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8728200

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档