Hi,
Here is your code that I changed a bit. I tested it and it works.
public function testpdfAction() {
$this->_helper->layout->disableLayout();
$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, 'utf-8');
$page->drawText('Hello world 222!', 100, 510, 'utf-8');
$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())
;
}
scs
On Thu, Mar 11, 2010 at 6:14 PM, Shadedream
<[email protected]> wrote:
>
> I'm testing out a tutorial for Zend PDF to see if it will be suitable for a
> project I'm working on, but I'm immediately running into an issue. I'm
> getting a blank PDF (with font embeded) with the following code:
>
> $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!', 100, 510);
>
> header("Expires: Sat, 01 Jan 2000 00:00:00 GMT");
> header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
> header("Content-type: application/pdf");
> echo $pdf->render();
>
> The only thing similar I've been able to locate was an old bug report from
> 2008 which ended up being resolved by fixing something with the iconv
> configuration (post did not elaborate) on a solaris server (which I am
> running on as well). Any ideas on what could be causing this, and if iconv
> what should be done? I don't have control of the server but if I know what
> to look for and request I can send it off to the server guys. Thanks in
> advance for any help.
>
> -Nick
> --
> View this message in context:
> http://n4.nabble.com/Zend-PDF-drawText-and-blank-PDF-files-tp1589208p1589208.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>