WebBrowser print to specified printer

A

Andrius B.

Hi all.

I'd like to print the document from WebBrowser to the specified printer, but
silently, t.i., not by calling ShowPrintDialog. The printer could be the
default system printer, but not in always. Accordingly, using
WebBrowser.Print() is not the solution.
I found one solution: change the system default printer to desired one, do
the print job and then change back the default printer to previous. Tha
problem is, that the user, who uses my app, may not have enough rights to
make some system changes.

Is there another method how to do it silently? Is there any other control
instead of WebBrowser for that purpose?

Thanks for any answer.
 
O

Onur Güzel

Hi all.

I'd like to print the document from WebBrowser to the specified printer, but
silently, t.i., not by calling ShowPrintDialog.  The printer could be the
default system printer, but not in always. Accordingly, using
WebBrowser.Print() is not the solution.
I found one solution: change the system default printer to desired one, do
the print job and then change back the default printer to previous. Tha
problem is, that the user, who uses my app, may not have enough rights to
make some system changes.

Is there another method how to do it silently? Is there any other control
instead of WebBrowser for that purpose?

Thanks for any answer.

You can try using PrinterSettings.PrinterName to specify a printer to
print through. Then try calling print method as in the example linked
below:
http://msdn.microsoft.com/en-us/library/system.drawing.printing.printersettings.printername.aspx

Note: You alsa may want to loop through InstalledPrinters to see the
exact name of desired printer:
http://msdn.microsoft.com/en-us/lib...inting.printersettings.installedprinters.aspx

HTH,

Onur Güzel
 
A

Andrius B.

Hi. Merhaba. :)

Thanks for the suggestion.
But that example on MSDN is how to print text file.
In may app, I have to print file of html format, witch includes table with
borders. I would like not to handle any print events, like in that example.
It would be event more complicated to draw letters and lines and so on. I
would like to simple use Print() method of PrintDocument object. Is it
possible?

Thanks again.





Hi all.

I'd like to print the document from WebBrowser to the specified printer,
but
silently, t.i., not by calling ShowPrintDialog. The printer could be the
default system printer, but not in always. Accordingly, using
WebBrowser.Print() is not the solution.
I found one solution: change the system default printer to desired one, do
the print job and then change back the default printer to previous. Tha
problem is, that the user, who uses my app, may not have enough rights to
make some system changes.

Is there another method how to do it silently? Is there any other control
instead of WebBrowser for that purpose?

Thanks for any answer.

You can try using PrinterSettings.PrinterName to specify a printer to
print through. Then try calling print method as in the example linked
below:
http://msdn.microsoft.com/en-us/library/system.drawing.printing.printersettings.printername.aspx

Note: You alsa may want to loop through InstalledPrinters to see the
exact name of desired printer:
http://msdn.microsoft.com/en-us/lib...inting.printersettings.installedprinters.aspx

HTH,

Onur Güzel
 

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