Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
TakeSnapshot
TakeSnapshot
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
Brian
- salvadordf
- Posts: 4304
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: TakeSnapshot
Fixed a couple of typos in that demo. Thanks!
Re: TakeSnapshot
I noticed that you are using uWVBrowser.CapturePreview, instead of uWVWindowParent.TakeSnapshot. Is there a difference?
Thanks
Brian
Thanks
Brian
- salvadordf
- Posts: 4304
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: TakeSnapshot
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.
It uses BitBlt and I'll remove it in the next update.
Re: TakeSnapshot
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
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
- salvadordf
- Posts: 4304
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: TakeSnapshot
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
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
Thanks,
It looks like is has already been reported:
https://github.com/MicrosoftEdge/WebView2Feedback/issues/579
Brian
It looks like is has already been reported:
https://github.com/MicrosoftEdge/WebView2Feedback/issues/579
Brian
Re: TakeSnapshot
It looks like Devtools Page.captureScreenshot has the same problem.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
Brian
Re: TakeSnapshot
Do you have any ideas on how to make this work; or am I going to have to start using CEF4Delphi instead?brche wrote: ↑Wed Feb 23, 2022 9:53 pmIt looks like Devtools Page.captureScreenshot has the same problem.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
Brian
Brian
- salvadordf
- Posts: 4304
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: TakeSnapshot
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.