View Full Version : save pdf with a given name
02-01-2005, 10:50 AM
I want to know if its posible to save de .pdf with a given standard name... for example: A_Nummer.pdf...
Thanks a lot!
02-01-2005, 11:01 AM
Saving the PDF-File is up to you - as you will be the one that supplies the FileOutputStream for the operation.
If you want to save the PDF file in a web-environment, then using the Content-Disposition header will do the trick (see RFC1945 (http://rfc.net/rfc1945.html) for the definition of the HTTP standard).
Have mo' fun,
02-03-2005, 08:11 AM
thanks taqua for your reply! but i still have the same problem... im not working with a web environment... im working with an application...
i dont know how to control the FileOutputStream with the JFreeReport. Is there any Property I can config to give the name? or do I have to change any library from the JFreeReports?
sorry, but im a litle bit lost...
thanks again! :oops:
02-03-2005, 12:17 PM
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:
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:
OutputStream out = new BufferedOutputStream(new FileOutputStream(new File(fileName)));
final PageFormat pf = report.getDefaultPageFormat();
final PDFOutputTarget target = new PDFOutputTarget(out, pf);
final PageableReportProcessor proc = new PageableReportProcessor(report);
Have mo' fun,