1

我的代码很简单:

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;

我有 Acrobat reader v9
ZF v1.11
错误消息:“无法打开此文件,因为它没有页面”
我错过了什么?

4

2 回答 2

3

您必须将页面添加到 pdf 中:

$pdf1->pages[] = $p1; 

这是一个关于 Zend_PDF 的不错的教程 http://devzone.zend.com/article/2525

于 2010-12-15T16:55:20.110 回答
2

要从手册中添加页面,您应该创建页面,对其进行修改,然后将其添加到您的 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();

应该管用。

于 2010-12-15T16:53:58.817 回答