Welcome Guest Search | Active Topics | Sign In | Register

WebView print Options
Christian
Posted: Thursday, June 4, 2020 5:56:26 AM
Rank: Newbie
Groups: Member

Joined: 6/4/2020
Posts: 2
Hi,

I would like to use your component in a server application that receives a list of documents to print and print them.

I managed to do it using the following code in a for each statement:

_eoThreadRunner.Send(() =>
{
var eoWebView = _eoThreadRunner.CreateWebView();
eoWebView.LoadUrlAndWait(documentFileUrl);
var printerSettings = new PrinterSettings {PrinterName = printerName};
eoWebView.Print(printerSettings);
});

My questions are:
- is this the right way to proceed or there is a better one?
- if it is the right way, when should I call the method Destroy of the eoWebView object? Calling it right after the Print method prevents the print to be executed. Is there a way to know when it's safe to call the Destroy method, something like "print enqueued, you can safely destroy the webview"?

Thank you very much!
eo_support
Posted: Thursday, June 4, 2020 11:49:54 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi,

Technically you do not need to create a new WebView for each print task. You can reuse the same WebView to load a Url, print it and then load the next Url, print it, and so on.

However you should not do this in a for each loop because Print is asynchronous. So you must wait for the Print to finish before you start the next iteration. There is no built in support for you to wait for the print to finish. However the print will always trigger a AfterPrint event (regardless whether the print was successful. So you can monitor that event in order to start the next iteration, or to destroy the WebView if needed.

Thanks!
Christian
Posted: Thursday, June 4, 2020 12:48:46 PM
Rank: Newbie
Groups: Member

Joined: 6/4/2020
Posts: 2
Great! Thank you very much!
eo_support
Posted: Thursday, June 4, 2020 12:51:04 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
No problem. Please feel free to let us know if there is anything else.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.