Page 1 of 1

Screenshot of whole page?

Posted: Tue Jan 14, 2020 8:53 am
by softtouch
I need to take a snapshot/save a bitmap of the whole loaded page, not just the visible part, so TakeSnapShot wont do it for me.
Is there any way to do that?
I am using the latest CEF4Delphi with Delphi 10.3.3, if that matter.

Re: Screenshot of whole page?

Posted: Tue Jan 14, 2020 9:42 am
by salvadordf
Hi,

If the page is not too big you can create a browser with the maximum dimensions and call TChromium.TakeSnapshot.
If it's too big you can use JavaScript to scroll and call TChromium.TakeSnapshot several times.

CEF doesn't have an API call to take snapshots and TChromium.TakeSnapshot is the only way we have to take them for the moment.

Perhaps we could use the "html5 canvas" in JavaScript as an alternative to take screenshots :
https://stackoverflow.com/questions/491 ... ts/6678156

Re: Screenshot of whole page?

Posted: Tue Jan 14, 2020 10:00 am
by softtouch
Thank you for the quick response!
The pages are unfortunately big, some more than 4000 pixel, so a TakeSnapShot isn't possible (via resizing the browser).
I am doing it at the moment using TWebBrowser, but TWebBrowser has other issues, so I was hoping I can do it with CEF4Delphi too somehow.
I guess I will then have to live with the TWebBrowser bugs and hoping that some day, CEF4Delphi will have a function to render the document to a bitmap.

Re: Screenshot of whole page?

Posted: Tue Jan 14, 2020 10:08 am
by salvadordf
You can also try a TChromium in OSR mode.

In that mode the page is rendered in a bitmap (or a DirectX texture). You would need to use the TChromium.OnGetViewRect event to set the browser dimensions and you will receive the raw pixels in TChromium.OnPaint.

However, If I remember correctly Chromium has a browser size limit and I'm not sure if you can create a browser with a 4000px height.