Welcome Guest Search | Active Topics | Sign In | Register

How to set/copy content of view1 to view2 Options
tschneider
Posted: Monday, October 1, 2018 12:38:53 PM
Rank: Newbie
Groups: Member

Joined: 9/5/2012
Posts: 4
Hello,

i am evaluating your WebBrowser Control for WinForms and i have a question:
I use the webBrowser instance and navigate to a special web site which requires a login.
After login and navigate through needed content i want to capture the navigated site (webview1) but in larger size then current webview1.

I thought i create a new background webview with larger size using Threadrunner.
But how can i set the content of webview1 to webview2 for capturing without re-login?


how can i achieve this?

best

Thomas
eo_support
Posted: Monday, October 1, 2018 1:31:22 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,221
I am not sure if I understand your question. The short answer is you can NOT copy WebView1's state to WebView2.

However session data such as log in sessions, may not be part of the WebView so in that case they do not need to be copied. For example, if you have logged in through WebView1 and it has created a persistent login cookie, then WebView2 will see this cookie when it loads resource from the same site. This works because the cookie storage is not part of WebView's state data. It's a storage that shared by all WebViews managed by the same browser engine instance.

Other information such as a WebView's scrolling offset, or the current value of a textbox, are strictly maintained by the WebView itself. There is no built in support for you to copy such state data directly to another WebView. It is possible for you to use JavaScript to fetch these values from WebView1 and then use some other JavaScript code to set this values in WebView2. However that will need to be done by your code. Once you have the correct JavaScript code, you can call WebView.EvalScript to run the script.
tschneider
Posted: Monday, October 1, 2018 2:43:33 PM
Rank: Newbie
Groups: Member

Joined: 9/5/2012
Posts: 4
thank you for fast response.
but how can i reuse the resources from webview1. is it enough to set the url from webview1 to webview2?

If not, have you a short snippet?

-Thomas
eo_support
Posted: Monday, October 1, 2018 2:50:45 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,221
There is no such thing as "reuse" between different WebViews. If you want WebView2 to display the same page as WebView1, you load the same Url into both WebVi8ews.
tschneider
Posted: Thursday, October 4, 2018 10:07:01 AM
Rank: Newbie
Groups: Member

Joined: 9/5/2012
Posts: 4
I have tried to load a secured website (using authentication) in webBrowser (webControl1.WebView) and navigate to the site that i want to capture.
But trying to capture the webpage (using new internal webview with larger size), i get a blank-page as result and not the displayed view.

Code-Snippet:

WebView wbView = new WebView();
wbView.Create(IntPtr.Zero);
wbView.Resize(5000,4000);
wbView.LoadUrlAndWait(webControl1.WebView.Url);
wbView.Capture().Save(@"c:\tiffs\clip\snap.bmp");


Is it possible to capture a webview with larger size than the webcontrols webview?

Hint:
The website is a kiosk for viewing newspapers digitized pages.

-Thomas
eo_support
Posted: Thursday, October 4, 2018 3:06:17 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,221
You can't do it this way. The load will not finish unless you are running a message pump. You would typically use a thread runner to resolve this issue:

https://www.essentialobjects.com/doc/webbrowser/start/webview_no_ui.aspx

Additionally, it's very likely that your resize and capture will fail on a size of 5000 * 4000. For performance reason, internally the browser engine uses hardware acceleration surface support provided by the video card/driver to compose the final output whenever it can. Since the primary purpose of such composition is for screen output, the GPU hardware and drivers usually do not maintain buffers that are significantly larger than a normal screen size, which means resizing the browser window to this size can often fail.

In your case, you can try to use this overload of Capture to capture the screen:

https://www.essentialobjects.com/doc/eo.webbrowser.webview.capture_overload_1.aspx

There are two key points about this function:

1. The captured area does not have to be the same as the screen area. This means you do NOT need to resize the WebView to cover the entire area you want to capture. The capture area is specified by the first argument of this method. The WebView size is not directly related to the capture area --- however it can affect the layout of the page. For example, if you have text that automatically wrap to the next line, then obviously a narrower window will produce more text lines;

2. The final image size is specified in the second argument. Typically this size can be used to scale down the size of the final image to avoid buffer allocation failure. For example, you can specify the capture area to be 5000 by 4000 but the final image size to be 500 by 400. This will significantly reduce the output image size thus make the call more likely to succeed. If you wish to have high resolution output, then you have two options:

a. Capture a smaller area. This is due to the same memory restrictions (not directly related to how much memory your system has but more to internal implementation of your GPU hardware/driver);
b. Use our HTML to PDF feature to render the page to PDF. PDF is rendered in vector format instead of bitmap. So it can maintain high quality and reasonable size at the same time (this is exactly why PDF is so popular). This option might work better for your purpose because PDF usually offers the best viewing quality since you can zoom in without losing quality;

Hope this helps. Please feel free to let us know if you still have any questions.

Thanks!


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.