By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,117 Members | 1,093 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,117 IT Pros & Developers. It's quick & easy.

Print HTML to PDF

P: n/a
I am trying to print an existing HTML File to PDF in VB.NET
programmatically.

I have only had success with setting the default printer to Acrobat
Distiller and using this code.

Dim MSHTML As SHDocVw.InternetExplorer
MSHTML = New SHDocVw.InternetExplorer()
MSHTML.Navigate("c:\html.htm)
MSHTML.Visible = False

MSHTML.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINT,
SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER , 0, 0)

MSHTML.Quit()
MSHTML = Nothing

I do not like this way because it is extremely slow.

I have tried using the System.Drawing.Printing as well.

Dim oPrint As System.Drawing.Printing.PrintDocument
oPrint = New System.Drawing.Printing.PrintDocument()
oPrint.DocumentName = "c:\html.htm"
oPrint.Print()

This way seems to work fine and creates a PDF document, but the PDF
documents are always blank. Does anyone know why this does this? And
does anyone know a good way to do this without having to buy a third
party component?

Nov 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.