Hi -
Thank you for writing such a useful tool. We have a web application that generates client-side charts and data tables (ag-grid), and we would like to provide our customers with a tool they can use to capture static images of the results for insertion into Powerpoint, etc.
I have been experimenting with EO.WebBrowser and EO.Pdf.
EO.pdf works well, but I think the insertion into Powerpoint would go more smoothly with PNGs.
With EO.WebBrowser, I am using webView.Capture, but I'm struggling with a few things:
1) If I don't specify a size when I call Capture, I am only getting a subset of my chart+data table (even after waiting long enough for everything to be rendered).
2) If I specify a rectangle when I call Capture, I get my chart+data table, but the ag-grid scrollbar is missing, and the result looks odd.
3) If I specify excludeScrollBars:=False in my call to Capture, I get back "Nothing" (and no error is thrown by the call to Capture).
So... I am wondering:
a) Is it possible to call webView.Capture with *both* excludeScrollBars:=False *and* a Rectangle to force the size?
b) Any ideas on what I might be doing wrong when I ask for excludeScrollBars := False?
c) Any ideas on why my call to webView.Capture() with no sizing rectangle doesn't return an image that is the size returned by webView.GetPageSize()?
Sample code below with comments.
thanks!
-Frank.
Code: Visual Basic.NET
'Create a ThreadRunner object
Dim threadRunner As New ThreadRunner()
'Create a WebView through the ThreadRunner
Dim webView As WebView = threadRunner.CreateWebView()
threadRunner.Send(Function()
'Load a page, wait up to 3 seconds for the reply
webView.LoadUrl(url).WaitOne(3000)
' Check initial size
Dim sizeA = webView.GetPageSize() ' Returns 800 x 400
' Wait a few seconds (hack) to confirm chart and data table rendered by Javascript
Threading.Thread.Sleep(6000)
' Check out size after everything is rendered
Dim sizeB = webView.GetPageSize() ' Returns 783 x 821
' SUCCESS but doesn't include all of chart and data table
' Do a capture and have a look at the size in the IDE
Dim capture As Object = webView.Capture()
Dim size = capture.Size() ' Returns 783 x 400
' SUCCESS but missing scroll bar
' Force a rectangle that is bigger than the chart + data table
Dim rect2 As New Rectangle(0, 0, 1000, 1000)
Dim capture2 As System.Drawing.Image = webView.Capture(rect2)
Dim size2 = capture2.Size() ' Returns 1000 x 1000 as expected
capture2.Save("C:\temp\temp2.png", Imaging.ImageFormat.Png)
' FAILURE - capture3 is "Nothing"
Dim capture3 As System.Drawing.Image = webView.Capture(excludeScrollBars:=False)
' Throws exception due to capture3 being "Nothing"
Dim size3 = capture3.Size()
End Function)