Question

My code is very simple:

header('Content-type: application/pdf');
header("Content-Disposition: attachment; filename=\"tesat.pdf\"");
$pdf1 = new Zend_Pdf();
$p1=$pdf1->newPage(Zend_Pdf_Page::SIZE_A4);
$p1->drawLine(10, 10, 40, 40);
echo $pdf1->render();
die;

I have Acrobat reader v9
ZF v1.11
Error message: "This file can not be opened because it has no pages"
what am I missing?

Was it helpful?

Solution

You have to add the page to the pdf:

$pdf1->pages[] = $p1; 

Here's a decent tutorial on Zend_PDF http://devzone.zend.com/article/2525

OTHER TIPS

To add a page from the manual, you should create the page, make your modification on it and then add it to your pdf.

header('Content-type: application/pdf');
header("Content-Disposition: attachment; filename=\"tesat.pdf\"");
$pdf1 = new Zend_Pdf();
$p1 = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
$p1->drawLine(10, 10, 40, 40);
$pdf1->pages[] = $p1;
echo $pdf1->render();

should work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top