Tuesday Jun 11, 2013

JavaFX WebView & JavaFX HTMLEditor: A Tale of Two Cities

Tough times in the world of Fosfor, the EPUB Open Toolbox. Turns out that while the JavaFX WebView has perfect rendering but no editing capabilities, the JavaFX HTMLEditor has perfect editing capabilities but crap rendering.

Exhibit one is right here, with the JavaFX HTMLEditor on the left and the JavaFX WebView on the right, rendering the same XHTML file:

As can be seen, the images, CSS, and entities defined in the XHTML file above are perfectly rendered in WebView, but not at all in the HTMLEditor. It seems to me that the HTMLEditor is meant for rendering text only, nothing else.

I then hacked my own HTMLEditor on top of the JavaFX HTMLEditor, which searches through all the text prior to rendering and uses the file protocol to locally locate images and CSS:


The result is as follows, i.e., I've fixed the images and CSS problem, but not the entities, yet:

In short, I'm going to try and create a set of service providers for a "fixHTMLEditorRendering" service which will pre-process images, CSS, and HTML entities prior to them being rendered in the JavaFX HTMLEditor. Then, when saving the file back to EPUB, I'm going to have to reverse the process.

Not ideal, but I think it's workable.

Issue: https://javafx-jira.kenai.com/browse/RT-30487


Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.


« June 2013 »