Search code examples
phphtmlpdfmpdf

How to get the output of a php file into a variable using mPDF


I'm using mPDF library to provide pdf files.

Assume that I have a file named facture.php that contains :

  • an image in the header

  • a table in the body

  • an image in the footer of the file

And another file named convert_HTML2PDF.php that will provide the pdf output of the first file.

I would like to get the output of the facture file that is interpreted into a variable and output it as a pdf file without visualising in the browser.

How can I do that and use the output inside the convert_HTML2PDF.php?


Solution

  • $mpdf->Output('filename.pdf', 'F');
    

    will send the output to a file on your server instead of a browser.

    See: http://mpdf1.com/manual/index.php?tid=125 For more output variations.