How to print header with dynamic values in mpdf?

-1

Personal I have a function that returns a $ html containing a list of users, even here it is working. my problem and when trying to generate pdf print header with last user from the list, it is not resetting the header or something similar.

I'm passing the $ html variable inside the method to generate header

mpdf-> SetHeader ($ html);

    
asked by anonymous 24.05.2016 / 20:49

1 answer

1

Dude, when such a question arises, go straight to documentation . The mpdf setHeader does not do what you want (iterate over a list of users and print a custom header for each one). What you should do is set a different header for each page. Example based on the most recent version of mpdf (taken from there):

<?php

// First ensure that you are on an Even page

$mpdf->AddPage('','E');

// Then set the headers for the next page before you add the page

$mpdf->SetHTMLHeader('<div style="text-align: right; border-bottom: 1px solid #000000; font-weight: bold; font-size: 10pt;">Chapter 2</div>','O');

$mpdf->SetHTMLHeader('<div style="border-bottom: 1px solid #000000; font-weight: bold; font-size: 10pt;">Chapter 2</div>','E');



$mpdf->AddPage();

$mpdf->SetHTMLFooter('<div style="text-align: right; font-weight: bold; font-size: 8pt; font-style: italic;">Chapter 2</div>','O');

$mpdf->SetHTMLFooter('<div style="font-weight: bold; font-size: 8pt; font-style: italic;">Chapter 2</div>','E');

$mpdf->WriteHTML('Rest of the document');

$mpdf->Output();

Basically you will go through your $ html array, and for each index (or its user) add a new page with a custom header.

    
27.05.2016 / 04:38