I have attached a perl script to convert HTML to PDF
Following is the code for the same
use HTML::HTMLDoc;
my $htmldoc = new HTML::HTMLDoc();
$htmldoc->set_input_file(“source.html”); # alternative to use a present file from your fs
my $pdf = $htmldoc->generate_pdf();
$pdf->to_file(‘foo.pdf’);
It actually works perfectly fine even if the HTML is not w3 validated. Neat if you have to convert HTML that was not created by you on the fly to PDF.
I also acknowledge that the same code is there in the CPAN’s synopsis of the module used. But it took me a few hours to locate it and to pick from the zillion other modules available there. Hope someone finds it useful.
If you are wondering why I posted this at such an ODD time. I was clearning out my notes and inbox items and saw a note to myself to post this in a blog. Horrors of GTD when the weekly reviews are not done! And as always if the task aint more than 2 mins, it aint worth putting in a to do list. And hence the post.