|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
What is your EO.WebBrowser.dll version number?
Thanks!
|
|
Rank: Member Groups: Member
Joined: 8/10/2014 Posts: 15
|
Hi,
DLL version is 3.0.79.0
Matjaž
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
Please try to download it from our download page again. I believe this was an issue for build 3.0.79 but was fixed in the current build (EO.Total 2014.0.14, EO.WebBrowser 3.0.80).
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 1/12/2015 Posts: 81
|
The following code does not resize the webview completely:
Code: Visual Basic.NET
wbView = New WebView
wbView.Create(IntPtr.Zero)
wbView.LoadUrlAndWait("http://www.ebay.com/sch/iPads-Tablets-eBook-Readers-/171485/i.html")
Dim s As Size = wbView.GetPageSize
wbView.Resize(s.Width, s.Height)
wbView.Capture().Save("c:\temp\snap.bmp")
Sometimes if I try it a few times in a row it will work. Also, which image formats can you save to with the Save method?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi benpm,
Resize is asynchronous. You can call WebView.DoEvents() with a small value to wait for it to complete. For example, WebView.DoEvents(200).
Capture returns a standard .NET System.Drawing.Image object to you. Save method is a method of the Image class and it is implemented by .NET, not by us. So you will need to consult other resources as to what format it supports.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 1/12/2015 Posts: 81
|
Adding WebView.DoEvents() worked. Thanks.
|
|
Rank: Advanced Member Groups: Member
Joined: 1/12/2015 Posts: 81
|
I'm using the version: 16.0.91.0 of EO.WebBrowser. The following code does not resize the webview at all:
Code: C#
ThreadRunner threadRunner = new ThreadRunner("ThreadRunner");
WebView wb = threadRunner.CreateWebView();
threadRunner.Send(() =>
{
var nav = wb.LoadHtml(html, url.ToString());
nav.WaitOne();
Size s = wb.GetPageSize();
wb.Resize(s.Width, s.Height);
for (var i = 0; i < 10; i++)
{
WebView.DoEvents(200 * (i + 1));
Image img = wb.Capture();
if (img.Width == s.Width || img.Height == s.Height || (img.Width >= s.Width * .9 && img.Height >= s.Height * .9))
{
bmSnapshot = new Bitmap(img);
break;
}
}
});
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
We have confirmed this to be a bug. This will be fixed in our next build. We will reply again as soon as the new build is posted.
Thanks!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
This is just to let you know that we have posted a new build that should fix this problem. You can download the new build from our download page.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 1/12/2015 Posts: 81
|
The following code is using a picturebox as the handle for the webview. And ExecuteJS is running some Javascript which hides some of the HTML elements on the page so the image looks cleaner.
Code: C#
void WaitForBrowserAndLoadBitmap(WebView wb, NavigationTask nav)
{
nav.WaitOne();
ExecuteJS(wb);
PictureBox pb = (PictureBox)this.Controls.Find("pb", false)[0];
Size s = wb.GetPageSize();
pb.Size = s;
pb.Refresh();
//force thread to sleep in order to allow UI to resize
Image img;
int sizeHasntChangedCount = 0;
int prevWidth = -1;
int prevHeight = -1;
do
{
Thread.Sleep(200);
img = wb.Capture();
s = wb.GetPageSize();
if (img != null && s.Width == prevWidth && s.Height == prevHeight)
{
sizeHasntChangedCount += 1;
}
else
{
prevWidth = s.Width;
prevHeight = s.Height;
sizeHasntChangedCount = 0;
}
} while (!(img != null && img.Width >= s.Width - 10 && img.Height >= s.Height - 10) && sizeHasntChangedCount < 5);
bmSnapshot = new Bitmap(img);
}
Everything is normally working fine. But I've found that under a heavy CPU and memory usage, "wb.Capture()" is always returning null. Is there a timeout to capture the image? Can this be increased?
|
|
Rank: Advanced Member Groups: Member
Joined: 1/12/2015 Posts: 81
|
I just did some more testing. When I change the "wb.capture()" to "wb.Capture(new Rectangle(0, 0, 1000, 3000))", it works. However, the actual size the image should be is: 1000x30998
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
benpm wrote:I just did some more testing. When I change the "wb.capture()" to "wb.Capture(new Rectangle(0, 0, 1000, 3000))", it works. However, the actual size the image should be is: 1000x30998 Hi, We have looked into this and you can't capture images of such huge size. Capturing an image of that size requires a huge screen buffer which often can not be allocated. When the screen buffer allocation fails, Capture will return null. The work around for this is to either scale the output image by providing a destSize argument to the Capture method, or call Capture multiple times so that you get multiple smaller images. You can then merge them into a single big image if desired --- keep in mind you may still run into out of memory error on the merging step. Thanks!
|
|