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.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

offscreen <canvas>dom to TBitmap

Post Reply
User avatar
salvadordf
Posts: 4620
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: offscreen <canvas>dom to TBitmap

Post by salvadordf »

Hi Roberto,
rdp wrote: Tue Sep 05, 2017 8:06 pm hello, I want use the chromium to generate charts,
here's fullfill of charts js libraries free,
now I was thinking, I put a offscreen chromium, load the js libraries then:
1) how to call javascript to passing data directly instead of GET HTTP
Use TChromium.ExecuteJavaScript. Several demos use the ExecuteJavaScript function in the context menu and they use
browser.MainFrame.ExecuteJavaScript but it's the same.
Take a look at the MiniBrowser or the JSExtension demos for example.
rdp wrote: Tue Sep 05, 2017 8:06 pm 2) how to save the canvas element to Delphi TBitmap
You need to use the OSR mode to take a snapshot.

The OSR mode is more complex than the "normal" mode. Compare the SimpleBrowser and the SimpleOSRBroser and you will see a lot more code.

If this is the first time you use CEF4Delphi, DCEF3 or any other CEF3 based project I would suggest that you use the SimpleBrowser first. Load your customized webpage with the libraries, pass the parameters with ExecuteJavaScript and when you see the right results then move your code to the SimpleOSRBrowser.

The SimpleOSRBrowser uses a TPaintBox32 to paint the results. You should be able to save the bitmap using the TPaintBox32.Buffer.SaveToFile function.
Post Reply