Php pdf创建显示一个错误";未能加载pdf文档";在泽德

Php pdf创建显示一个错误";未能加载pdf文档";在泽德,php,pdf,zend-framework,Php,Pdf,Zend Framework,我曾尝试使用fpdf、dompdf和zend_pdf创建pdf,但总是显示错误“无法加载pdf文档”。我在大多数网站上搜索解决方案,我的步骤与他们的步骤相同。我的代码如下 FPDF --------- require_once('fpdf/fpdf.php'); $pdf = new FPDF(); $pdf->AddPage(); $pdf->SetFont('Arial', 'B', 16); $pdf->Cell(4

我曾尝试使用fpdf、dompdf和zend_pdf创建pdf,但总是显示错误“无法加载pdf文档”。我在大多数网站上搜索解决方案,我的步骤与他们的步骤相同。我的代码如下

    FPDF
    ---------
    require_once('fpdf/fpdf.php');
    $pdf = new FPDF();
    $pdf->AddPage();
    $pdf->SetFont('Arial', 'B', 16);
    $pdf->Cell(40, 10, 'Hello World!');
    $pdf->Output("dom.pdf");

    DOM PDF
    ---------
    require_once('dompdf/dompdf_config.inc.php');           
    $dompdf = new DOMPDF();
    $outfile = 'invoice.pdf';
    $dompdf = new DOMPDF();
    $dompdf->load_html("<h1>shihab</h1>");
    $dompdf->render();
    $dompdf->stream($outfile);

    ZEND_PDF
    -----------
    $pdf = new Zend_Pdf();
    $pdf->pages[0] = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
    $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
    $pdf->pages[0]->setFont($font, 16);
    $pdf->pages[0]->drawText("Shihab", 10, 800, 'UTF-8');
    $pdf->save("dom.pdf");
FPDF
---------
一次需要_('fpdf/fpdf.php');
$pdf=新的FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'helloworld!');
$pdf->Output(“dom.pdf”);
DOM PDF
---------
需要一次('dompdf/dompdf_config.inc.php');
$dompdf=新的dompdf();
$outfile='invoice.pdf';
$dompdf=新的dompdf();
$dompdf->load_html(“shihab”);
$dompdf->render();
$dompdf->stream($outfile);
ZEND_PDF
-----------
$pdf=new Zend_pdf();
$pdf->pages[0]=新的Zend_pdf_页面(Zend_pdf_页面::大小为A4);
$font=Zend_Pdf_font::fontWithName(Zend_Pdf_font::font_HELVETICA);
$pdf->pages[0]->setFont($font,16);
$pdf->pages[0]->drawText(“Shihab”,10800,“UTF-8”);
$pdf->save(“dom.pdf”);

请帮帮我,我终于找到了自己的理由。问题是我的页面完全没有转换为内容类型application/pdf。事实上,这发生在我的项目中,当我在每个操作中使用布局页面时。我已经通过在pdf创建操作中禁用布局修复了这个问题,只需使用以下代码

Zend_Layout::getMvcInstance()->disableLayout();

同时使用$this->\u helper->layout->disableLayout(true);