Jump to content

Archived

This topic is now archived and is closed to further replies.

ovig

Cannot get Zend Framework (Zend_Pdf) to work

Recommended Posts

Hi,

I'm trying to use the Zend Framework to generate PDF's on the fly, and get the damn thing to work. It's probably not a bug - just me missing something - but for the life of me, I can't see what ;-)

First of all, here's the apache log file with the details of the problem:

Code:

[code][client 127.0.0.1] PHP Notice: Use of undefined constant self::PAGESIZE_A4 - assumed 'self::PAGESIZE_A4' in /usr/share/php5/ZendFramework-0.1.3/library/Zend/Pdf/Page.php on line 184
[...and then one more line like this for every other PAGESIZE...]
[client 127.0.0.1] PHP Notice: Use of undefined constant self::FONT_TIMES_ROMAN - assumed 'self::FONT_TIMES_ROMAN' in /usr/share/php5/ZendFramework-0.1.3/library/Zend/Pdf/Resource/Font/Standard.php on line 36
[...and then one more line like this for every other FONT...]
[client 127.0.0.1] PHP Fatal error: Uncaught exception 'Zend_Pdf_Exception' with message 'Wrong font name' in /usr/share/php5/ZendFramework-0.1.3/library/Zend/Pdf/Resource/Font/Standard.php:37\nStack trace:\n#0 /usr/share/php5/ZendFramework-0.1.3/library/Zend/Pdf/Resource/Font/Standard.php(37): Zend_Pdf_Font_Standard::__construct()\n#1 /srv/www/htdocs/eSecurity/invoice.php(86): Zend_Pdf_Font_Standard->__construct('Courier')\n#2 {main}\n thrown in /usr/share/php5/ZendFramework-0.1.3/library/Zend/Pdf/Resource/Font/Standard.php on line 37[/code]

I know that only the last logline is the actual error, but as there are a lot of notices that seem to be somewhat related, I've included them.

The code that produces this error is below - it is pretty much directly taken from the Framework documentation:

Code:

[code]<?php
set_include_path ('/usr/share/php5/ZendFramework-0.1.3/library');
require_once 'Zend/Pdf.php';
$pdf = new Zend_Pdf();
$pdf->pages[] = new Zend_Pdf_Page(Zend_Pdf_Const::PAGESIZE_A4);
$pdfPage->setFont(new Zend_Pdf_Font_Standard(Zend_Pdf_Const::FONT_COURIER), 12); $page->drawText("Company",50,200);
?>

[/code]

The Framework is installed in /usr/share/php5; it is part of the include path thanks to the set_include_path() call - and that seems to be working OK as the path is picked up in the logs, and the call to the Zend_Pdf and Zend_Pdf_Page constructors are OK.
I run all this on a OpenSUSE 10.0 box, with the standard apache2- PHP 5.0.4, and v0.1.3 of the Framework (downloaded as a "package" rather than from the SVN repository).

Thanks in advance,

ovig

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.