View Full Version : save pdf with a given name
Anonymous
02-01-2005, 10:50 AM
Hi!!
I want to know if its posible to save de .pdf with a given standard name... for example: A_Nummer.pdf...
Thanks a lot!
Lu.
Taqua
02-01-2005, 11:01 AM
Hi,
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,
said Thomas
Anonymous
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:
Taqua
02-03-2005, 12:17 PM
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:
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);
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