简体   繁体   English

使用 FPDF 创建的 pdf 文件 output 为空(PHP)

[英]pdf file output created with FPDF are empty (PHP)

Hi and thanks by advance for you helps.您好,提前感谢您的帮助。

I'm trying to write on a PDF with FPDF on PHP.我正在尝试在 PHP 上使用 FPDF 编写 PDF。

I'm actually working on WordPress.我实际上正在研究 WordPress。

If I'm using this code on my first website, it's working well:如果我在我的第一个网站上使用此代码,它运行良好:

if (isset($_GET["obtenir-mon-analyse"])){
  $pdfFile = getcwd() . '/wp-content/themes/childtheme/ressources/PDF_analyse_template.pdf';
  require_once('library/fpdf/fpdf.php');
  require_once('library/fdpi/src/autoload.php');

  // initiate FPDI
  $pdf = new setasign\Fpdi\Fpdi();
  // add a page
  $pdf->AddPage("L");
  // set the source file
  $pdf->setSourceFile($pdfFile);
  // import page 1
  $tplIdx = $pdf->importPage(1);
  // use the imported page and place it at point 10,10 with a width of 100 mm
  $pdf->useTemplate($tplIdx, 0,0 );

  $pdf->Output('I');

}

But, with the same code on another website, the PDF generated by the output function is empty (0kb).但是,在另一个网站上使用相同的代码,由 output function 生成的 PDF 为空(0kb)。

Also, the template is working because FDPF is well detecting the available page number.此外,该模板正在工作,因为 FDPF 可以很好地检测可用页码。

PS: PS:

  • The 2 website are hosting on the same host. 2 个网站托管在同一主机上。
  • I have not any error.我没有任何错误。

I really don't know where is the problem.我真的不知道问题出在哪里。

Thanks a lot.非常感谢。

I think nobody will see this answer but:我认为没有人会看到这个答案,但是:

  • On wordpress在 wordpress
  • With the plugin WP-optimize使用插件 WP-optimize
  • If you use the mimify option on HTML, you will not be able to use FPDF如果您在 HTML 上使用 mimify 选项,您将无法使用 FPDF

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM