I'm trying to generate a PDF file on the fly using Zend_Pdf. I'm able to draw
lines and shapes just fine, however I can't seem to draw text. I'm testing
on a localhost on my MacBook Pro running MAMP and Zend 1.11.8. Below is the
code that I'm using, which I found on another website:
----------
public function testpdfAction()
{
$this->_helper->viewRenderer->setNoRender();
$pdf = new Zend_Pdf();
$page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
$pdf->pages[] = $page;
$page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES),
20);
$page->drawText('Hello world 111!', 185, 585);
$page->drawText('Hello world 222!', 100, 510);
$response = $this->getResponse();
$response
->setHeader('Cache-Control', 'public', true)
->setHeader('Content-Description', 'File Transfer', true)
->setHeader('Content-Disposition', 'attachment;
filename=test.pdf', true)
->setHeader('Content-Type', 'application/x-pdf', true)
->setHeader('Content-Transfer-Encoding', 'binary', true)
->setBody($pdf->render())
;
}
----------
I've tried the above code on a remote server running Debian, and including
the same version of Zend, and it works perfectly, however it won't work on
my MacBook/MAMP machine. I do all of my work locally so I really need to be
able to get this to work on my MacBook.
I've searched high and low and I can only find two other threads regarding
this problem, both of which refer to the iconv configurations. Mine are all
set at ISO-8859-1 and I'm not sending through any special characters, so as
far as I know I don't need to use UTF-8. Nonetheless, I've tried UTF-8 and
it still won't work.
Can anyone else please? I'm at the end of my tether!
--
View this message in context:
http://zend-framework-community.634137.n4.nabble.com/Zend-Pdf-drawText-not-working-tp3712004p3712004.html
Sent from the Zend Framework mailing list archive at Nabble.com.
--
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]