PDF Header & Footer on all pages


#1

Hey all,

if you want to customize your template with your own header and footer, you have to edit your mdpf_helper.php in your directory (\application\helpers). If you open now the file, you have to change the things, I highlighted.

<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

function pdf_create($html, $filename, $stream = TRUE)
{

    require_once(APPPATH . 'helpers/mpdf/mpdf.php');

    $mpdf = new mPDF();
 -->$mpdf->setHTMLHeader('<img src="Fill in your PNG"/>');***
    $mpdf->defaultheaderfontsize=10;
-->$mpdf->setHTMLFooter('<img src="Fill in your PNG"/>');***
    $mpdf->SetAutoFont();

    $mpdf->WriteHTML($html);

    if ($stream)
    {
        $mpdf->Output($filename . '.pdf', 'I');
    }
    else
    {
        $mpdf->Output('./uploads/temp/' . $filename . '.pdf', 'F');
        
        return './uploads/temp/' . $filename . '.pdf';
    }
}

?>

#2

I am not sure how to use this code block cause now I see different content there. Is this code still working? And, if so, the change needed is just these two lines?


#3

@azurro Could you update the code block for version 1.4.9?


#4

@Kovah for sure!