【发布时间】:2016-10-14 00:34:05
【问题描述】:
我正在尝试使用带有 php 的 fpdf 库生成一个 pdf 文档,但我在 chrome 中收到错误 Failed to load PDF document。我能够在 Firefox 中正确查看文档。下面是我试图生成pdf的代码。有人可以帮忙吗?提前致谢。
<?php
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);
ob_start();
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial', 'B', 16);
$pdf->Cell(40, 10, 'Hello World!');
header('Content-type: application/pdf');
header('Content-Transfer-Encoding: binary');
header("Content-Disposition: inline; filename='example2.pdf'");
$pdf->Output('example2.pdf', 'I');
ob_end_flush();
?>
【问题讨论】:
-
在我的 chrome 中它工作正常。希望你不要忘记
include('fpdf/fpdf.php');? -
是的,我已经包含了
fpdf.php,事实上我可以在 Firefox 中查看该文件。 -
那么解决了吗?如果是,请发布答案。
-
@krishna89:你解决了这个问题吗?
标签: php google-chrome pdf fpdf