user3162878
user3162878

Reputation: 608

How to view pdf while working with mpdf?

I am working on codeignitor and doing work for generating report. But my problem is that everytime i ve to download pdf file to view anything which is taking seriously too much time.

Here is the link of mpdf manual http://www.mpdfonline.com/repos/mpdfmanual.pdf

here is my code which i am working. If somebody know something plz help:

Controller: Report.php

public function index(){
    $html =$this->load->view('report/index', $this->data, true);
    $htmls=$html;
    $this->load->library('Mpdf_land');    
    $pdfFilePath = 'Public_Opportunities_Detail('.date('Y-m-d H:i:s').').pdf';                  
    $this->mpdf_land->pdf->WriteHTML($htmls);
    $this->mpdf_land->pdf->Output(UPLOAD_REPORT_PATH.$pdfFilePath.'', "D");
}

View File: index.php

<html>
<body>
    <p>hello </p>
</body>
</html>

Upvotes: 1

Views: 4342

Answers (1)

ArtOsi
ArtOsi

Reputation: 943

You could change the "D" in output function to "I" $this->mpdf_land->pdf->Output(UPLOAD_REPORT_PATH.$pdfFilePath.'', "I"); so then file should be displayed inline in browser instead of downloading it.

Or if it is only the matter of HTML output in developing and you don't need the pdf at all you can just print it. Something like print_r($htmls); exit;

Upvotes: 2

Related Questions