我曾尝试使用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");
请帮助
答案 0 :(得分:1)
Zend_Layout::getMvcInstance()->disableLayout();