【问题标题】:Class 'Zend\ZendPdf\PdfDocument' not found找不到类“Zend\ZendPdf\PdfDocument”
【发布时间】:2014-03-17 21:37:24
【问题描述】:

在我的控制器中:

use ZendPdf\PdfDocument;
public function monthlyReportPdfAction(){
    $pdf = new PdfDocument();
    $pdf->pages[0] = new Page( Page::SIZE_A4 );$pdf->pages[0]->setFont( Font::fontWithName( Font::FONT_HELVETICA ), 24 );$pdf->pages[0]->drawText( 'Hello world!', 240, 400 );
    $pdf->save( 'example.pdf' );
}

供应商中的我的zendpdf 我在索引中创建了一个 .phtml 和一个 href,

【问题讨论】:

    标签: php zend-framework pdf


    【解决方案1】:

    如果您尝试单独使用 ZendPdf Stand,您可以查看之前的答案: Zend PDF

    您可能还想查看标准自动加载器的 ZF2 文档,其中提供了有关命名空间的详细信息。 ZF2 Standard Autoloader

    【讨论】:

    • 我又更新了作曲家????现在我的问题已经解决了,但是当我点击我的 pdf 超链接时出现空白屏幕??????举一些例子
    【解决方案2】:
    use ZendPdf\Font as Font;
    use ZendPdf\Page as Page;
    use ZendPdf\PdfDocument as PdfDocument;
    

    在课堂上:

     public function exportpdfAction()
        {
            $pdf = new PdfDocument();
    
            $pdf->pages[0] = new Page( Page::SIZE_A4 );
            $pdf->pages[0]->setFont( Font::fontWithName( Font::FONT_HELVETICA ), 24 );
            $pdf->pages[0]->drawText( 'Hello world!', 240, 400 );
            $pdf->save();
    
            return new ViewModel();
        }
    

    在 composer.json 中

    "zendframework/zendpdf": "*"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-02
      • 2015-02-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-26
      相关资源
      最近更新 更多