【问题标题】:FPDF exports .html instead of .pdf, only on MacFPDF 导出 .html 而不是 .pdf,仅在 Mac 上
【发布时间】:2021-01-14 15:01:33
【问题描述】:

我正在使用 PHP 库 FPDF 在我的网站上生成 PDF。 它适用于除 Mac 以外的所有设备。它保存一个 .html 文件而不是 .pdf。 甚至 iPhone 也能完美运行。 这是我的代码:

<?php
        
require('includes/fpdf/fpdf.php');

class PDF extends FPDF {}
$mypdf = new FPDF();

// Content of PDF begins
// [...]
// Content of PDF ends

$file = utf8_decode('test.pdf');
$mypdf->Output('F', 'includes/exports/'.$file);
header('Content-Type: application/pdf');
header("Content-Disposition: attachment; filename=\"". basename($file) ."\""); 
readfile('includes/exports/'.$file);
exit(); ?>
        

感谢您的帮助!

【问题讨论】:

  • 您在 Mac 电脑上使用的是哪种浏览器?
  • 我使用的浏览器是Safari

标签: php macos pdf export fpdf


【解决方案1】:

实现它的唯一方法是存储 PDF 并向用户显示下载链接。很好的解决方法

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-03
    • 2017-06-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多