Question

I am trying to generate a pdf from the html content which has been entered using the mpdf library.

Is there any possibilities of limiting the number of pages. For example: I want only two pages not more than that.

Était-ce utile?

La solution 2

You don't have to specify the maximum number of pages, you simply add a fixed maximum number of pages programmatically after having set the page size.

$mpdf = new mPDF('utf-8', 'A4');

so now you have A4 pages, now you add the specified number of pages.

If instead you want to use html as a long line of text

$mpdf->WriteHTML('<div id="text"><p>Bla bla</p></div>', 2);

you might need to measure somehow how long your html is based on the page format, that might not be as easy as it sounds.

Autres conseils

I suppose you can override mpdf class addPage method, and if the number of pages is more then you want, generate EnoughPagesException, catch it up in your code, and there you have the mpdf object with the number of pages you need.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top