【问题标题】:How to pass action output to TCPDF in Zend framework如何在 Zend 框架中将动作输出传递给 TCPDF
【发布时间】:2013-06-25 17:26:38
【问题描述】:

您好,我是 zend 框架的新手。我在 zend 框架中使用 TCPDF。我在以 pdf 格式打印内容时遇到问题。

我在控制器中编写了以下代码:

$html = ob_get_clean();

         $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

            $pdf->SetCreator(PDF_CREATOR);
            $pdf->SetAuthor('Test');
            $pdf->SetTitle('Test');
            $pdf->SetSubject('Test');
            $pdf->SetKeywords('TCPDF, PDF, example, test, guide');

            $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
            $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));

            $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

            $pdf->SetMargins(PDF_MARGIN_LEFT, 20, PDF_MARGIN_RIGHT);

            $pdf->SetHeaderMargin(20);

            $pdf->SetFooterMargin(25);

            $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

            $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

            $pdf->setFontSubsetting(true);

            $pdf->SetFont('dejavusans', '', 8, '', true);

            $pdf->AddPage();

            $pdf->setTextShadow(array('enabled'=>true, 'depth_w'=>0.2, 'depth_h'=>0.2, 'color'=>array(196,196,196), 'opacity'=>1, 'blend_mode'=>'Normal'));

            $pdf->writeHTMLCell($w=0, $h=0, $x='', $y='', $html, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);

            $datetime=date("Y-m-d h:i:s");

            $pdf->Output('MIS_Report_'.$datetime.'.pdf', 'I');

并且我已经将我的内容写入了要在 pdf 上显示的 views 文件夹中的 phtml 文件中。

当我运行我的代码时。它会向我显示pdf,但不显示任何内容。 请帮帮我

【问题讨论】:

    标签: zend-framework tcpdf


    【解决方案1】:

    如果你不需要布局

    $this->_helper->layout()->disableLayout();
    $html = $this->view->render('controllername/actionname.phtml');
    

    【讨论】:

    • 我有另一个问题,当我将数据从数据库传递到 pdf 的 phtml 文件时,它会给出一个错误“未定义的索引:/cmiportal/cm/cmi013/library/tcpdf/tcpdf.php 中的 cols第 21971 行“
    猜你喜欢
    • 2015-05-18
    • 1970-01-01
    • 2018-05-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多