Page 1 of 1
TakeSnapshot
Posted: Fri Feb 11, 2022 5:13 pm
by brche
Not a big problem; but your procedure to take a Snapshot in the MiniBrowser demo is named akeSnapShot. I think it should be TakeSnapShot
Brian
Re: TakeSnapshot
Posted: Sat Feb 12, 2022 8:55 am
by salvadordf
Fixed a couple of typos in that demo. Thanks!
Re: TakeSnapshot
Posted: Wed Feb 16, 2022 11:44 pm
by brche
I noticed that you are using uWVBrowser.CapturePreview, instead of uWVWindowParent.TakeSnapshot. Is there a difference?
Thanks
Brian
Re: TakeSnapshot
Posted: Thu Feb 17, 2022 8:20 am
by salvadordf
TakeSnapshot is an old function copied from CEF4Delphi that doesn't work with WebView2.
It uses BitBlt and I'll remove it in the next update.
Re: TakeSnapshot
Posted: Wed Feb 23, 2022 5:44 pm
by brche
It looks like CapturePreview does not work when the browser (or Window Parent?) is hidden.
We hide the form and take snapshots of the browser to display to the user. This does not seem to work when the form is hidden.
Brian
Re: TakeSnapshot
Posted: Wed Feb 23, 2022 6:05 pm
by salvadordf
This seems to be an upstream issue in WebView2.
Try using the Page.captureScreenshot DevTools method :
https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-captureScreenshot
The MiniBrowser demo of the CEF4Delphi project uses it here :
https://github.com/salvadordf/CEF4Delphi/blob/03f9e9a1b9860ece476e1c9f667937d53370008d/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas#L1288
https://github.com/salvadordf/CEF4Delphi/blob/03f9e9a1b9860ece476e1c9f667937d53370008d/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas#L1370
Calling devtools methods in WebView4Delphi is very similar but you will have to use a JSON parser to get the result data and then use TNetEncoding.Base64.DecodeStringToBytes to decode it.
You may also report this CapturePreview issue in the official WebView2 Feedback repository :
https://github.com/MicrosoftEdge/WebView2Feedback
Re: TakeSnapshot
Posted: Wed Feb 23, 2022 7:24 pm
by brche
Thanks,
It looks like is has already been reported:
https://github.com/MicrosoftEdge/WebView2Feedback/issues/579
Brian
Re: TakeSnapshot
Posted: Wed Feb 23, 2022 9:53 pm
by brche
salvadordf wrote: Wed Feb 23, 2022 6:05 pm
This seems to be an upstream issue in WebView2.
Try using the
Page.captureScreenshot DevTools method :
https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-captureScreenshot
The MiniBrowser demo of the CEF4Delphi project uses it here :
https://github.com/salvadordf/CEF4Delphi/blob/03f9e9a1b9860ece476e1c9f667937d53370008d/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas#L1288
https://github.com/salvadordf/CEF4Delphi/blob/03f9e9a1b9860ece476e1c9f667937d53370008d/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas#L1370
Calling devtools methods in WebView4Delphi is very similar but you will have to use a JSON parser to get the result data and then use TNetEncoding.Base64.DecodeStringToBytes to decode it.
You may also report this CapturePreview issue in the official WebView2 Feedback repository :
https://github.com/MicrosoftEdge/WebView2Feedback
It looks like Devtools Page.captureScreenshot has the same problem.
Brian
Re: TakeSnapshot
Posted: Tue Mar 08, 2022 6:37 pm
by brche
brche wrote: Wed Feb 23, 2022 9:53 pm
salvadordf wrote: Wed Feb 23, 2022 6:05 pm
This seems to be an upstream issue in WebView2.
Try using the
Page.captureScreenshot DevTools method :
https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-captureScreenshot
The MiniBrowser demo of the CEF4Delphi project uses it here :
https://github.com/salvadordf/CEF4Delphi/blob/03f9e9a1b9860ece476e1c9f667937d53370008d/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas#L1288
https://github.com/salvadordf/CEF4Delphi/blob/03f9e9a1b9860ece476e1c9f667937d53370008d/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas#L1370
Calling devtools methods in WebView4Delphi is very similar but you will have to use a JSON parser to get the result data and then use TNetEncoding.Base64.DecodeStringToBytes to decode it.
You may also report this CapturePreview issue in the official WebView2 Feedback repository :
https://github.com/MicrosoftEdge/WebView2Feedback
It looks like Devtools Page.captureScreenshot has the same problem.
Brian
Do you have any ideas on how to make this work; or am I going to have to start using CEF4Delphi instead?
Brian
Re: TakeSnapshot
Posted: Wed Mar 09, 2022 8:48 am
by salvadordf
I haven't checked these methods but I would also try :
- Moving the TWVWindowParent control to a position outside the screen like (-1000, -1000) instead of setting the visibility to false.
- Using JavaScript to take screenshots : https://stackoverflow.com/questions/42828187/how-to-take-a-screenshot-in-html-with-javascript
- Using the WindowlessBrowser demo and modify TWVDirectCompositionHost.UpdateSize to move the visual to (-1000, -1000) or set a clipping rect with zero width and height instead of setting the visibility to false.
If all these points fail and you can't wait until the WebView2 project fixes this issue then you can move to CEF4Delphi.