Hi,
ok, I assume now, that you don't use the JFreeReport-GUI and that you already got the name of the file from the user (or defined it elsewhere).
The simplest way to save the report is to use the PDFReportUtil class. It defines a default implementation of the report processing code that writes the generated content to a file:
Code:
String filename = // created elsewhere
JFreeReport report = // created elsewhere
PDFReportUtil.createPDF (report, filename);
If you need more control over the write process, then this is the code that performs the writing:
Code:
OutputStream out = new BufferedOutputStream(new FileOutputStream(new File(fileName)));
final PageFormat pf = report.getDefaultPageFormat();
final PDFOutputTarget target = new PDFOutputTarget(out, pf);
target.configure(report.getReportConfiguration());
target.open();
final PageableReportProcessor proc = new PageableReportProcessor(report);
proc.setOutputTarget(target);
proc.processReport();
target.close();
out.close();
Have mo' fun,
said Thomas