How to print WebBrowser control content without showing print dialog?
In the recent versions of the WebBroswer
control, Print()
prints to the default printer without showing any dialog:
webBrowser1.Print();
It's equivalent to getting an instance of IWebBrowser2
from the WebBrowser.ActiveXInstance
property and then call its ExecWB
method by passing OLECMDID_PRINT
as command and OLECMDEXECOPT_DONTPROMPTUSER
to specify not showing the prompt:
int OLECMDID_PRINT = 6;
int OLECMDEXECOPT_DONTPROMPTUSER = 2;
dynamic iwb2 = webBrowser1.ActiveXInstance;
iwb2.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, null, null);
Or in a single line of code:
((dynamic)webBrowser1.ActiveXInstance).ExecWB(6, 2, null, null);
Printing a page without the Print dialog box?
I think you have confused client side printing with printing on the server.
You can print on the client side with Java, how some coupon printers work. However, this is frowned upon. The client should always have a choice of how they want it printed.
The calls on Page_Load
would be done on the server-side printers.
Related Topics
Internal Server Error While Running a Simple .Net Core MVC Application on Ubuntu 16.04
How to Detect Iis Version Using C#
Using a Wwwroot Folder (ASP.NET Core Style) in ASP.NET 4.5 Project
C# - Elegant Way of Partitioning a List
Windows Phone 8: Media File Access
Filesystemwatcher to Watch Unc Path
Twoway-Bind View's Dependencyproperty to Viewmodel's Property
Wpf Webbrowser (3.5 Sp1) Always on Top - Other Suggestion to Display HTML in Wpf
How to Get the Value of a Session Variable Inside a Static Method
Should I Use Mkannotation, Mkannotationview or Mkpinannotation
How to Determine a Timezone by The Utc Offset
How to Compare Two Objects in Unit Test
When Should I Use Out Parameters
Using Ienumerable Without Foreach Loop
JavaScript: Alert.Show(Message) from ASP.NET Code-Behind