Welcome Guest, Not a member yet? Register   Sign In
Getting a Corrupt PDF all the time. (Using dompdf)
#1

[eluser]Solarpitch[/eluser]
Hi Guys,

I've been reading through all posts and cant find a possible solution to this. Everytime a PDF is generated it is corrupt and cant be read by Adobe Reader. This is what I have...


Controller ...

Code:
class Invoice extends Controller{
    
    function Invoice()
    {
    
        parent::Controller();
        
    }
    
    function index()
    {

    $data['title'] = 'Some title';
    $data['heading'] = 'Some Head';
    $this->load->helper('file');
    $this->load->plugin('to_pdf');    
    $html =  $this->load->view('pdf/invoice', $data, true);
    pdf_create($html, 'Test',FALSE);
    
     }

}

to_pdf_pi.php

Code:
if (!defined('BASEPATH')) exit('No direct script access allowed');
function pdf_create($html, $filename)
{
  require_once('dompdf/dompdf_config.inc.php');

  $dompdf = new DOMPDF();
  $dompdf->load_html($html);
  $dompdf->render();
  $dompdf->stream($filename.'.pdf');
}


view

Code:
<body>

    <h3>&lt;?=$title;?&gt;</h3>
    <p>&lt;?=$heading;?&gt;</p>

&lt;/body&gt;
&lt;/html&gt;

I have the dompdf directory inside my plugins folder also. The PDF generation seems to work outside of the framework but just not when I try to adapt it this this approach for Codeigniter.

Any help would be great as I have a tight deadline for a project that needs a PDF feature Sad.

Thanks.
#2

[eluser]TheFuzzy0ne[/eluser]
I'd suggest you look into how to set the encoding; I suspect that may be the problem here.
#3

[eluser]Solarpitch[/eluser]
Thanks for your reply. Do I set the encoding via CI or through dompdf? I take it I'll have to download an encoding class or something?




Theme © iAndrew 2016 - Forum software by © MyBB