I am using MPDF to generate a pdf file from HTML, the document is a legal document that in a particular jurisdiction requires all pages to filled top to bottom with text i.e. the paragraphs of text can not stop half way down the page.
I have looked at auto calculating remaining space and adjusting line heights etc but it seems to be overly complicated and difficult to do when the amount of text can vary from document to document.
Does anyone know a way / function that can be used within mPDF to automatically do this?
Assuming that the legal document will not be just a single-line sentence.
In that case one can use a loop.
So, please run the following script (e.g.
pre-genpdf.php) to initalize the setting:After that, click the hyperlink to trigger the following
genpdf.phpPlease note that I have used some PHP documentation as
$teststring0for testing, for real case please use the actual textual data of your legal document.It will generate
temp.pdfin the loop (just ignore it, each iteration over the loop will generate this temp file, overwriting the previous one since they are of the same name), but finally will generate thefinal.pdfwhich is the one with best line-height and then the process will STOP.See the result
Note: for better result you may adjust the increment value of line-height each time from 0.05 to say 0.01 (each time smaller step) and the result may even be better, but of course it may then take longer time for the iteration to complete.