【问题标题】:Zend Framework PDF not working - document has no pagesZend Framework PDF 不工作 - 文档没有页面
【发布时间】:2023-04-09 12:24:01
【问题描述】:

我的代码很简单:

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
采埃孚 v1.11
错误消息:“无法打开此文件,因为它没有页面”
我错过了什么?

【问题讨论】:

    标签: php zend-framework pdf-generation zend-pdf


    【解决方案1】:

    您必须将页面添加到pdf:

    $pdf1->pages[] = $p1; 
    

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

    【讨论】:

    • 我认为 $pdf1->newPage(....) 应该将页面添加到数组中,哦,好吧 - 谢谢!
    【解决方案2】:

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

    应该可以。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多