Scaling WebEngine.print output

Mark Claassen markclaassenx at
Thu Oct 6 16:58:09 UTC 2016

I am having a problem with printing from the WebEngine.  What I am trying
to do is create a page of SVG, render it to the WebEngine, and print it.  I
don't completely control the SVG, but I know it needs to fit on one page.
So, what I would like to do is be able to control the scaling and
positioning of the WebEngine manually.

I found that I can do this using JavaScript, but this gets a bit ugly.  The
WebEngine.load seems to be rendered on a background thread, however the
WebEngine.executeScript calls execute immediately.

This ends up creating a complex call structure so that I can guarantee that
these JavaScript methods are not called before they can be executed.  I am also
forced to know more about the DOM than I would like to.  It would be nice
if there were some methods that could tell me what the bounding box is, and
then let me translate this if I need to.  (I realize that there would
likely be a unit conversion necessary as well.)

Example JavaScript methods:
executeScript("document.getElementsByTagName('svg')[0].currentTranslate.x =


More information about the openjfx-dev mailing list