【问题标题】:Fpdf edited files not displaying in browsers?Fpdf编辑的文件未在浏览器中显示?
【发布时间】:2014-11-20 08:59:11
【问题描述】:

我使用 fpdf 库添加了一些文本。添加的文本显示在 adobe reader 中,但是当我使用浏览器打开这些文件时,文本不可见。 我只能使用我的 adobe 阅读器程序查看这些文本。

$fullPathToFile = $target_path;

class custom_PDF extends FPDI {

    var $_tplIdx;
    var $file;

    function Header() {
    global $cur_path_to_fil2e;      
    if (is_null($this->_tplIdx)) {
        // THIS IS WHERE YOU GET THE NUMBER OF PAGES
        $this->numPages = $this->setSourceFile($this->file);
        $this->_tplIdx = $this->importPage(1);
    }
    $this->useTemplate($this->_tplIdx, 0, 0, 200);
    }

    function Footer() {

    }

    function setFile($param) {
    $this->file = $param;
    }

}

$pdf234 = new custom_PDF();
$pdf234->setFile($fullPathToFile);
$pdf234->AddPage();
$pdf234->SetFont('Arial','B',14);
$pdf234->SetTextColor(0, 0, 0);
$utf8text = $current_user->user_login . "(" . str_ireplace('_', ' ', $current_user->roles[0]) . ")," . get_bloginfo('name') . "," . get_bloginfo('url') . "\n" . date("d M Y,h:i:s a");
$pdf234->Write(5, $utf8text, get_bloginfo('url'));
if ($pdf234->numPages > 1) {
    for ($i = 2; $i <= $pdf234->numPages; $i++) {
    $pdf234->_tplIdx = $pdf234->importPage($i);
    $pdf234->AddPage();
    $pdf234->Write(5, $utf8text, get_bloginfo('url'));
    }
}
$pdf234->Output($line['name'], 'D');

【问题讨论】:

  • 你使用的是最新的 fpdf_tpl.php 文件吗
  • FPDI - 版本 1.5.2
  • 您能否分享一个 PDF 结果并指出这些浏览器视图中哪些内容有问题?

标签: php pdf pdf-generation fpdi


【解决方案1】:

感谢大家的帮助。 我找到了答案。我刚刚在我的代码中添加了一个 die(),效果很好。

$pdf234->Output($line['name'], 'D');
die();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-04-15
    • 2014-05-11
    • 1970-01-01
    • 1970-01-01
    • 2020-04-03
    • 1970-01-01
    • 2020-03-06
    • 2017-03-27
    相关资源
    最近更新 更多