dompdf在使用localhost的浏览器中流pdf,但在网络ip中不 [英] dompdf stream pdf in browser using localhost, but not in network ip

查看:135
本文介绍了dompdf在使用localhost的浏览器中流pdf,但在网络ip中不的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道为什么dompdf在通过192.168.1.77之类的网络ip下载之前在浏览器中不流pdf,但是它可以在localhost上工作。

i need to know why dompdf doesn't stream a pdf in browser before download on network ip like 192.168.1.77 , but it works on localhost.

在使用时网络IP,它会立即下载文件,不会在浏览器中显示pdf预览

when using network ip, it just immediately download the file , it won't show pdf preview in browser

我正在使用dompdf版本0.6.2
,这是我的代码

i'm using dompdf version 0.6.2 this is my code

$dompdf = new DOMPDF();
    ob_start();

    $this->load->view('report_me',array_merge($this->sesi,$this->session->userdata('printdata')));
    // header('Pragma','public');
    $html = ob_get_contents();
    ob_end_clean();

    // $this->session->unset_userdata('printdata');
// $dompdf->set_option('setIsHtml5ParserEnabled', true);


    $dompdf->load_html($html);

// (Optional) Setup the paper size and orientation
// $dompdf->setPaper('A4', 'potrait');

// Render the HTML as PDF
    $dompdf->render();
    $canvas = $dompdf->get_canvas();
    $font = Font_Metrics::get_font("helvetica", "bold");
    $canvas->page_text(44, 760, "Page {PAGE_NUM} of {PAGE_COUNT}", $font, 8, array(0,0,0));

//ERASE SESSION

// Output the generated PDF to Browser
    $dts = date('Y-m-d');
    // $dompdf->output();
    // $dompdf->stream();
    $dompdf->stream('inv_'.$this->Master_model->getInvoiceNumber().'_'.$dts.'.pdf',array('Attachment'=>0));

我启用了


ENABLE_REMOTE

ENABLE_REMOTE

为TRUE

好像我我是唯一一个遇到问题的人,希望有人可以帮助我解决这个问题。

Seems like i'm the only one that face the problem, hope someone can help me through this..

推荐答案

在Laravel和尝试添加标题。

Encountered a similar problem on Laravel and tried adding headers. Doesn't work.

我在 stream() exit; c $ c>,它开始显示。我猜想框架可能在 stream()之后正在执行某些操作,导致标头恢复为 text / html

I added exit; after stream() and it started displaying. I am guessing the framework may be doing something after stream() causing headers to revert to text/html.

这篇关于dompdf在使用localhost的浏览器中流pdf,但在网络ip中不的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆