WebBrowser printing with PrintDocument

  • Thread starter Patrick Westerhoff
  • Start date
P

Patrick Westerhoff

Hello,

I need to print a HTML file and want to preset some page settings before the
printing starts (especially landscape), so that the user do not have to set
this first (the landscape is determined according on the displayed page, and
I plan to only display known pages).
So I used the WebBrowser Element to render the HTML page and I'm now trying
to set the page settings without executing the WebBrowser.ShowPageSetupDialog
method. However it seems as if the WebBrowser Control does not support this
directly, but the System.Drawing.Printing.PrintDocument object does.
So is it possible to generate a PrintDocument object from a WebBrowser page
so I can set printer settings? Or can I somehow else set the printer settings
without having the user interact and set it manually? Maybe with some API
command?

Thanks for help
Patrick Westerhoff
 
P

Patrick Westerhoff

I have found some information so far on changing the default page settings
for Internet Explorer, so i could change the registry before using the
WebBrowser.Print method and change the values back after it finished:
http://support.microsoft.com/kb/313723/EN-US/
http://support.microsoft.com/kb/236777/EN-US/

However this still leaves up the most important setting: page orientation. I
need to set this as some documents, I try to print have landscape enabled but
some not. And the printing should be rather automatically, so the (local
btw.) HTML document is opened and printed (maybe with selecting a printer
before, but not more).
So is there some API command, so that I can change page orientation, maybe
the default value of a printer, so I can change it temporarily and it works
correctly?

I also read about some IE-CSS hacks that rotate the objects on the HTML
page, but that won't work for me, as the documents contain multiple tables
that also break over pages and at that point the rotation fails.

Thank you
Patrick Westerhoff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top