0

I am using ReportMill to generate a report. The following is the code which generates a pdf document.

My question is: How do I pass the generated pdf document to a filechooser in Javafx ?

This so that it enables the user to save it to a folder of his choice. ReportMill itself can save the generated pdf to a string path specified as indicated in the code snippet below.

However once the application is installed on different computers instead of finding out user home directory, I would like to use a filechooser so that the generated pdf is saved to a directory of the users choice.

        RMDocument report = template.generateReport(adminRecords);

        report.getBytesPDF();

        FileChooser fileChooser = new FileChooser();
        fileChooser.setTitle("Save Report To : ");
        FileChooser.ExtensionFilter filter = new   FileChooser.ExtensionFilter("PDF files (*.pdf)", "report.pdf");
        fileChooser.getExtensionFilters().add(filter);

        fileChooser.showSaveDialog(stageReport);

The following line can save to the path specified:

    report.writePDF("c:/Users/xyz/Desktop/Report.pdf");

But as I mentioned that is not what I want. Would appreciate any help with this thanks.

  • look at [Saving Files](http://docs.oracle.com/javafx/2/ui_controls/file-chooser.htm). – SedJ601 Apr 15 '17 at 02:16
  • [This](http://java-buddy.blogspot.com/2012/05/save-file-with-javafx-filechooser.html) may be a better example for your case. – SedJ601 Apr 15 '17 at 02:19
  • Thanks Sedrick, yes I had browsed through those examples as well, I cant figure out how to create a file using the pdfbytes function in reportmill and then passing that specific file thus generated to the filechooser. So that it can be saved as pdf – supernova.surfer Apr 15 '17 at 13:28

0 Answers0