PDF Report Generation using JFreeReport

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
skm2011
Posts: 1
Joined: Thu Feb 10, 2011 12:12 pm
antibot: No, of course not.

PDF Report Generation using JFreeReport

Post by skm2011 » Thu Feb 10, 2011 1:29 pm

Hi All,
Is there any way to generate pdf using JFreeReport without saving in the disc. The pdf needs to be displayed instantly on browser without saving on the disc. The following piece of code is taking care of pdf generation. But by default it is saving the pdf on disc. Please let me know, in case of any solution.
public static boolean savePDF (final JFreeReport report, final String fileName)
{
OutputStream out = null;
try
{
File file = new File(fileName);
//LogUtil.logDebug("---->File name is "+fileName);

out = new BufferedOutputStream(new FileOutputStream(file));
final PDFOutputTarget target = new PDFOutputTarget(out);
target.configure(report.getReportConfiguration());
target.open();
final PageableReportProcessor proc = new PageableReportProcessor(report);
proc.setOutputTarget(target);
proc.processReport();

target.close();

return true;
}
catch (Exception e)
{
LogUtil.logError("Saving PDF failed1.");
e.printStackTrace();

}
finally
{
try
{
if (out != null)
{
out.close();
}
}
catch (Exception e)
{
LogUtil.logError("Saving PDF failed2.");
e.printStackTrace();
}
}

return false;

}

Locked