Rendering cefBrowser content without window/JFrame

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

Rendering cefBrowser content without window/JFrame

Postby sokolovAS » Mon Nov 28, 2016 3:57 am

Hi everyone!
Our usecase of jcef - we need to use chromium from java on windows for printing html to pdf.
We already add cefBrowser.printToPDF(..) method JNI binding to JCEF. And we want that JCEF loads some html, renders it without showing anywhere (i mean it parses html-css-js, process all of this, and "stops" at point when it can be displayed or printed), and then we call cefBrowser.printToPDF(..) and it prints content to pdf file.
The problem is, that we only know one way of initializing and using CefBrowser from java (on windows) - as in test example:
- we create cefBrowser,
- add its UI component to some JFrame
- setVisible(true) to this JFrame
- this opens OS window and starts CEF rendering process (we can see new process of jcef_helper.exe in windows dispathcer)
And this way doesnt work if we want to run this app as windows service (actually this runs inside of tomcat, and works perfectly if we start tomcat manualy as executable console app from some logged user, and doesnt work if we start this as windows service), cuz, as i am guessing, windows service doesnt create and visualize window (maybe GUI subsystem is turned off in windows service?), and that doesnt init CEF rendering process (we dont see jcef_helper.exe process). And as result cefBrowser.printToPDF(..) does nothing.

So, my questions is:
- can we initialize cefBrowser and start rendering process without window/JFrame at all?
- can someone explain why simple way doesnt work with windows service?

I dont have expertise in Windows, Java-AWT or CEF, just general concepts.

I'll be very grateful if someone can help me. Or enlighten me about JCEF-AWT-Windows.

UPD: partly solved the issue - u can set service property "allow windows service to interact with desktop"
but it still create windows (that waste resources and need additional manegment), can we avoid that?
sokolovAS
Newbie
 
Posts: 4
Joined: Thu Nov 24, 2016 8:10 am

Re: Rendering cefBrowser content without window/JFrame

Postby magreenblatt » Mon Nov 28, 2016 12:04 pm

Look at how off-screen rendering is implemented in JCEF. You can create a browser that doesn't display anything on the screen.
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm


Return to JCEF Forum

Who is online

Users browsing this forum: No registered users and 21 guests