Offscreen rendering

Having problems with building or using the JCEF Java binding? Ask your questions here.

Offscreen rendering

Postby fmilano » Sun May 28, 2017 1:32 pm

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
fmilano
Newbie
 
Posts: 2
Joined: Sun May 28, 2017 1:25 pm

Re: Offscreen rendering

Postby Czarek » Tue May 30, 2017 1:05 pm

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?
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. I'm available for contract work, see my resume.
User avatar
Czarek
Virtuoso
 
Posts: 1829
Joined: Sun Nov 06, 2011 2:12 am

Re: Offscreen rendering

Postby guich » Mon Aug 05, 2019 4:39 pm

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.
guich
Techie
 
Posts: 19
Joined: Tue Jul 30, 2019 10:11 am

Re: Offscreen rendering

Postby guich » Mon Aug 05, 2019 6:04 pm

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
guich
Techie
 
Posts: 19
Joined: Tue Jul 30, 2019 10:11 am


Return to JCEF Forum

Who is online

Users browsing this forum: No registered users and 2 guests