Set the printer to landscape for the WebBrowser Control
I am printing an HTML file by using the WebBrowser Control, but I want 开发者_JAVA技巧to force it to print landscape. I thought the following might do the trick but it didn't
Dim ps As New System.Drawing.Printing.PrinterSettings
ps.DefaultPageSettings.Landscape = True
WebBrowser1.ShowPrintDialog()
Is there any way of doing this that doesn't resort to SetPrinter APIs?
This is not possible. While the user is capable of setting printer settings (and even able to select a different printer) using the user interface, this is not possible programatically.
Some "hacks" exist where users set values in the registery directly (for the Internet Explorer keys), but mistakes here could be problematic.
Refer to the following Microsoft Knowledge base article: http://support.microsoft.com/kb/313723 Also a connect issue on this: https://connect.microsoft.com/VisualStudio/feedback/details/678232 And another related StackOverflow question: How do I programatically change printer settings with the WebBrowser control?
精彩评论