使用 Zend 框架创建 PDF
我正在使用 Zend Framework 和继承类,即 My_Pdf (我从 sourceforge 获得的,My_Pdf 库用于绘制表格)从数据库创建 PDF 文件。当我创建没有表格轮廓的 PDF 文件时,它运行良好并生成 PDF。但是当我尝试绘制与数据相对应的表格时,出现错误,
Fatal error: Declaration of My_Pdf_Page::drawImage() must be compatible with that of Zend_Pdf_Canvas_Interface::drawImage() in C:\Users\TranceServe\Zend\workspaces\DefaultWorkspace7\Crushed_PLanet\library\My\Pdf\Page.php on line 369
请指导我该怎么做。
I am using Zend Framework and inherited classes i.e. My_Pdf (that i got from sourceforge and My_Pdf library is used to draw tables)to create PDF file from database. When I create PDF file without table outlines it is working well and generating PDF. But when i try to draw table corresponding to data, I got an error,
Fatal error: Declaration of My_Pdf_Page::drawImage() must be compatible with that of Zend_Pdf_Canvas_Interface::drawImage() in C:\Users\TranceServe\Zend\workspaces\DefaultWorkspace7\Crushed_PLanet\library\My\Pdf\Page.php on line 369
Please guide me what to do.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我自己也遇到过这个问题。我没有在 1.11.3 中测试,而是在 1.11.0 中测试。您所要做的就是更改 My_Pdf_Page 中的方法 drawImage 并将参数 $image 指定为对象类型“Zend_Pdf_Resource_Image”:
I came across this problem myself. I've not tested in 1.11.3, but in 1.11.0. All you have to do is change your method drawImage in My_Pdf_Page is specify the argument $image as being of object type 'Zend_Pdf_Resource_Image':
这意味着派生类的蓝图与继承层次结构中较高的类不同。
这很可能意味着 PDF 库尚未更新以支持最新的 Zend Framework 版本。
您正在使用 Zend Framework 版本 1.11.3 但是...
很明显,您尝试使用的库是为 Zend Framework 编写的1.8(第一个框),自 2009 年 5 月(第二个框)以来就没有更新过,因此现在没有人再下载它了(第三个框)。
课程:了解你的工具!
This means that the blueprint of a deriving class is not identical to a class higher up in the inheritance hiearchy.
And this most probably means that the PDF library has not been updated to work with the latest Zend Framework version.
You are using Zend Framework version 1.11.3 BUT...
Very obviously the library you are trying to use was written for Zend Framework 1.8 (first box), it has not been updated since May 2009 (second box) and therefore nobody downloads it anymore these days (third box).
Lesson: Know your tools!