7 Replies Latest reply: Apr 4, 2012 2:00 AM by r.rohm RSS

    Printable and Graphics in JavaFX - future strategy?

    r.rohm
      Hi all,

      I need JavaFX for a business application that requires reporting, printing and also a print preview. What would be the best approach for creating complex layouts (text, tables, graphics, images, graphs, various fonts etc.), having the application display a (WYSIWYG!-)print preview and printing them, just as displayed in the preview?

      In Swing, I resort to the Printable/Pageable API and the Graphics/Graphics2D classes - all AWT classes. As far as I can see, JavaFX is not related to AWT in any way. So, can anyone point out how to implement such requirements using JavaFX for the UI - and for createing the print layout?

      Some details on my motivation:
      1) The API of JavaFX would be great for implementing complex layouts.
      2) Using two different graphics APIs & layers (JavaFX + AWT) does not seem to make sense to me. And, AFAIK JavaFX is not only meant to replace Swing, but likewise AWT.
      3) The most important: Printing support is a "must-have", maybe even mission critical.
      Recently, I talked about JavaFX with decision makers at a development company. They make several business applications, built on Java, with several thousands of customers. They asked repeatedly for printing support. They said, customers keep asking how to print all those nice diagrams. They just want to print what the see. The want it, just like they want to print web pages from a browser. And, in a browser, they can - and in JavaFX they cannot (so it seems). At present, that makes JavaFX a difficult topic for decision makers ... :-(

      I would be very glad about opinions, hints and - if possible - some info concerning printing from the JavaFX team :-)

      Best regards,
      R. Rohm

      Edited by: r.rohm on 03.04.2012 09:06
        • 1. Re: Printable and Graphics in JavaFX - future strategy?
          MiPa
          The request for printing support is already a very old request but up to now there is no solution.
          This feature request of mine from june 2011 http://javafx-jira.kenai.com/browse/RT-14016 links to other
          related requests. Although the last comment states that this feature will be considered for the next
          release after 2.0 I have not seen any support for it in the latest 2.1 snapshot.
          • 2. Re: Printable and Graphics in JavaFX - future strategy?
            sirius
            If you need reporting and printing capabilities right now you could take advantage of a dedicated reporting framework like JasperReports and integrate any JasperReports specific elements into your JavaFX application. See, http://jasperforge.org/projects/jasperreports
            • 3. Re: Printable and Graphics in JavaFX - future strategy?
              866035
              Might be better news, see jira:

              http://javafx-jira.kenai.com/browse/RT-17383

              Probably can't hurt voting for it too.

              Dave.

              Edited by: 863032 on Apr 3, 2012 8:53 PM
              • 4. Printable and Graphics in JavaFX / reporting tools?
                r.rohm
                @sirius

                Thank you for the tip!
                Do you have any experiences with e.g. JasperReports used together with JavaFX?

                As far as I see, the viewer components are Swing components, which would require the application to be a swing application (since I cannot embed a Swing component in a JavaFX app.) - correct?

                In respect to the JavaFX roadmap (JavaFX substituting Swing) I rather would avoid building Swing apps that embed JavaFX scenes.
                • 5. Re: Printable and Graphics in JavaFX - future strategy?
                  r.rohm
                  @Dave

                  Thank you, I voted :-)

                  Maybe also interesting: there are two more jira records concerning printing:

                  http://javafx-jira.kenai.com/browse/RT-17662
                  http://javafx-jira.kenai.com/browse/RT-13843

                  Robert
                  • 6. Re: Printable and Graphics in JavaFX / reporting tools?
                    jsmith
                    the viewer components are Swing components, which would require the application to be a swing application (since I cannot embed a Swing component in a JavaFX app.) - correct?
                    I used a Swing pdf viewer in a JavaFX application.

                    When I wanted to display a pdf, I just invoked the main method on the Swing pdf viewer which created a Swing JFrame and it all seemed to just work. Of course, it isn't an officially supported integration point. As long as the Swing portions of the app are being rendered in their own JFrame rather than a JavaFX managed Stage and you are careful about any threading callback issues, then displaying a Swing based report from a JavaFX app seems like it should be pretty straight-forward and a pretty quick and low-risk solution.

                    http://java.net/projects/pdf-renderer
                    http://java.net/projects/pdf-renderer/sources/svn/content/trunk/demos/viewer/com/sun/pdfview/PDFViewer.java?rev=140
                    http://code.google.com/p/willow-browser/
                    • 7. Re: Printable and Graphics in JavaFX / reporting tools?
                      r.rohm
                      @jsmith

                      Thank you! That's good news.
                      I'll give it a try as soon as possible.