I am using Codename One.
In my program I generate html code dynamically. I would like to grab a screenshot of the web browser view so I can send the screenshot as an image to users.
I've tried calling browserComponent.paint(Graphics)
to draw this onto a mutable image but this resulted in a blank image. Is there a way to do this?
You can't grab a screenshot of a peer component.
HTML is rendered natively in the OS as a
PeerComponent
see this blog post explaining peer components. Unfortunately peer components are rendered separately so you can't grab a screenshot of a peer.You can draw anything you want onto an Image using mutable images but you can't grab the image of an arbitrary peer. Check out our graphics section in the developer guide to see how one draws on an image.