Programmatically Changing the Destination Printer for the WinForms WebBrowser Control

I am trying to use an invisible WebBrowser control to print a very simple HTML document. Our application requires that we can print several documents in this way and that all of them can be sent to different printers. Unfortunately, I did not very successfully conclude on the correct printer.

The way it works right now is that before printing a document, the application determines which printer should receive it and sets the default printer accordingly. To do this, use SetDefaultPrinter (), imported from WinSpool.drv. If I find the code in debug mode, I can clearly see that the default printer is changing (and this change is reflected in the control panel user interface), but WebBrowser still insists on using the original default printer.

The MSDN documentation, from what I saw, does not really provide a solution for this scenario. I would greatly appreciate that I can do this programmatically.

+5
source share
3

, , , , - ( , -), ? , , .


, , , .

, , .

.

1). IE, webbrowser, API ActiveX. / API .

2). ( IE) printto . , Acrobat Reader , :

""C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe""  /t "%1" "%2" "%3" "%4"

, () . Google printto, ., , PrintTo ShellExecute.

3). HTML .NET, IE. , HTML (, , CSS) , , , , , . , . , , , , , . , , , . , .

4). , , /; , . OpenOffice .. ..

5). HTML (- ) (, PDF), , . ​​

+1

, .NET WebBrowser, .

0

.NET 3.5,

this.webBrowser1.ShowPrintDialog();
-1

All Articles