Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting HTML file to PDF using Win32/MFC

As part of my application, my client has requested that I include an automated e-mailing system. As part of this system, I generate HTML code and use automation to send it via. Outlook.

However, they also require a PDF copy of the HTML document to be sent as an attachment. My initial attempts involved using libHaru, which proved difficult to use efficiently, as I was required to create the PDF document from scratch, which required computation of the position of each of the lines in a table, and positioning of all the text, etc.

I was wondering if there would be a way to programmatically convert HTML code (or an HTML file if need be) into a PDF document either by using Win32/MFC itself or an external library.

Thanks in advance!

EDIT: Just to clarify, I am looking for solutions which minimize external dependencies.

like image 205
Thomas Russell Avatar asked Dec 04 '25 17:12

Thomas Russell


1 Answers

You should evaluate this utility wkhtmltopdf: http://code.google.com/p/wkhtmltopdf/

You can call it from the command line without the need to run a setup.

I use it generating my output documents as html then cal a ShellExecute(...) to convert it to PDF. It's great!

Inside uses webkit + qt. So compability with modern HTML is OK.

Hope it helps.

like image 68
Albertino80 Avatar answered Dec 06 '25 09:12

Albertino80



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!