亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

DOMPDF 無法在 codeigniter 中的實時服務器上工作

DOMPDF 無法在 codeigniter 中的實時服務器上工作

PHP
慕森卡 2023-06-24 18:05:39
我正在使用 codeigniter 框架和 dompdf 生成 pdf 。它在本地主機上工作得很好,但在實時服務器上顯示 500 錯誤。我嘗試過調試,但 error_log 文件中沒有顯示任何錯誤。這是函數generate_pdf的代碼。 public function generate_pdf($content, $name = 'download.pdf', $output_type = null, $footer = null, $margin_bottom = null, $header = null, $margin_top = null, $orientation = 'P'){    $this->load->library('pdf');    $html = '';    if (is_array($content)) {        foreach ($content as $page) {            $html .= $header?'<header>'.$header.'</header>':'';            $html .= '<footer>'.($footer?$footer.'<br><span class="pagenum"></span>' : '<span class="pagenum"></span>').'</footer>';            $html .= '<body><div class="page">'.$page['content'].'</div></body>';        }    } else {        $html .= $header?'<header>'.$header.'</header>' : '';        $html .= $footer?'<footer>'.$footer.'</footer>' : '';        $html .= $content;    }    $this->pdf->set_option('isPhpEnabled', true);    $this->pdf->set_option('isHtml5ParserEnabled', true);    $this->pdf->set_option('isRemoteEnabled', true);    $this->pdf->set_option('enable_html5_parser', TRUE);    // $this->pdf->set_option("DOMPDF_ENABLE_HTML5PARSER", true);    // $this->pdf->loadHtml($html);    $html = preg_replace('/>\s+</', '><', $html);    // $this->pdf->loadHtml($contents);    $this->pdf->loadHtml($html);    // $dompdf->load_html($html);         $this->pdf->setPaper('A4', ($orientation == 'P' ? 'portrait' : 'landscape'));       // $dompdf->set_option('enable_html5_parser', TRUE);    $this->pdf->render();    // $this->pdf->stream("dompdf_out.pdf", array("Attachment" => true));    // exit(0);        if ($output_type == 'S') {        // $output = $dompdf->output();        $output = $this->pdf->output();        write_file('assets/uploads/' . $name, $output);        return 'assets/uploads/' . $name;    }     else {        $this->pdf->stream($name);        return true;    }}
查看完整描述

1 回答

?
HUWWW

TA貢獻1874條經驗 獲得超12個贊

如果您使用的是 Dompdf 0.8.5,這是您的異常行

[$this->protocol, $this->baseHost, $this->basePath] = Helpers::explode_url($file);

如果這適用于本地主機但不適用于實時服務器,這可能是 PHP 版本的問題,因為此行使用 PHP 7.1 中引入的新語法


查看完整回答
反對 回復 2023-06-24
  • 1 回答
  • 0 關注
  • 129 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號