How do I generate PDF of HTML in a custom module? I want to generate PDF in my custom module. Using print module we can print node. But I have made html in my custom module and that I wanted to make pdf and save it in files.

I have tried custom dompfg library but its working. 
i wanted to do something like this:

$html = "&lt;h1&gt;Header&lt;/h1&gt;&lt;P&gt;Pdf generated.&lt;/p&gt;";

include ("mpdf.php"); /// This will be something to include for mpdf 
$mpdf=new mPDF('win-1252','A4','','',20,15,48,25,10,10); 
$mpdf-&gt;WriteHTML($html);
$mpdf-&gt;Output('../default/files/users/filename.pdf','F'); 
exit;


Any suggestions?
There is quite a bit more involved in integrating Drupal with the mPDF library than the code snippet you show.

As often with Drupal, there is a module for that. It is named PDF using mPDF, and this is what it will do:


  This module is used for Conversion of HTML pages to PDF documents using mPDF PHP Library. It allows you to generate a pdf document of any node.


Make sure you follow the instructions in the README.txt files carefully. You need to place the mPDF library in the right directory, and install the Libraries API, for it to work correctly.