Hi Everyone,
I have one windows service that i want to print HTML files. So far in debug mode service is able to print the HTML document but when installed the same service print operation would not take place.
We want to override the Print pop-up and send print directly to a default printer so that user need not to click on print button and no selection of printer required.
In application flow is some thing like following.
Web application call Print -> Call the Web API method (hosted using windows service)-> Print method write HTML to temp folder and Send print to default printer.
Following method written for printing the page.
public void PerformPrint(string url, string title = "untitled", int copies = 1) {if(string.IsNullOrEmpty(url))
throw new ArgumentException("The url can't be null or empty");
Navigate(url);
for (var i = 0; i < copies; i++) {
//Whithout those lines your app will crash
const int enabledAndSupported =
(int) OLECMDF.OLECMDF_SUPPORTED + (int) OLECMDF.OLECMDF_ENABLED;
while ((int)_webBrowser2.QueryStatusWB(OLECMDID.OLECMDID_PRINT) != enabledAndSupported) {
Application.DoEvents();
}
//****************************************************************************************
_webBrowser2.ExecWB(
OLECMDID.OLECMDID_PRINT,
OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER,
null,
IntPtr.Zero);
}
}
please help.
Thanks & Regards,
Naveen Upadhyay