Page 1 of 1

Offscreen rendering

PostPosted: Sun May 28, 2017 1:32 pm
by fmilano
Hi. I want to render a web page offscreen, and never show it in a window. I have found that if I do not create a JFrame with the getUIComponent() returned canvas, then the drawing area is never invalidated and the Paint event is never called. If that happens, the Browser object is never created on the C++ side and each call to one of its methods fails silently, returning on each call to JNI_GET_BROWSER_OR_RETURN instead of getting the browser object.
How should I use programatically the browser so it renders the page (my idea the is printing the contents) without having to create a JFrame and showing it?

Thank you in advance!

Fede

Re: Offscreen rendering

PostPosted: Tue May 30, 2017 1:05 pm
by Czarek
For the OnPaint event to get called, you have to call CefBrowserHost::WasResized in CEF.

Have you tried embedding CEF browser in a hidden window?

Re: Offscreen rendering

PostPosted: Mon Aug 05, 2019 4:39 pm
by guich
Hi,

Were someone able to do this?

Creating an invisible frame didn't work because the paint method is never called. But creating a frame is bad because another icon appears on task bar.

Re: Offscreen rendering

PostPosted: Mon Aug 05, 2019 6:04 pm
by guich
I was able to achieve this using:

JWindow frame = new JWindow(new JFrame("") // hack to enable keypress
{
public boolean isShowing()
{
return true;
}
});
frame.setOpacity(0f);
frame.setFocusable(true);

also, must set bounds to valid positions or the paint will never be called