[Solved] PDF Report Generation

You will have to by-pass the pdf_create() function in helpers/mpdf.php and deal with mpdf directly as explained in these posts:

and in the mpdf manual

For instance, to get the invoice aging report in landscape you would rewrite the corresponding function in modules/reports/controllers/reports.php as:

public function invoice_aging()
{
    if ($this->input->post('btn_submit'))
    {
        $data = array(
            'results' => $this->mdl_reports->invoice_aging()    
    );

    $html = $this->load->view('reports/invoice_aging', $data, TRUE);

    // we are not using the mpdf helper
    // $this->load->helper('mpdf');
    // pdf_create($html, lang('invoice_aging'), TRUE);

    // but we need the mpdf library
    require_once(APPPATH . 'helpers/mpdf/mpdf.php');
        
    $mpdf = new mPDF('c', 'A4-L');    
    $mpdf->SetAutoFont();
    $mpdf->WriteHTML($html);
    $mpdf->Output($filename . '.pdf', 'I');
    }
    $this->layout->buffer('content', 'reports/invoice_aging_index')->render();
}

where “A4-L” indicates the page size and orientation.

Miquel

1 Like