문제

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?

도움이 되었습니까?

해결책

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

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top