PDA

View Full Version : Printing



Anonymous
09-19-2002, 01:18 PM
Hi, I'm wondering can I print report without preview?

Thanks again, JFreeReport is a absolutly amazing stuff.

Anonymous
09-19-2002, 03:47 PM
Hi,

create a ReportPane, this is a Printable Object, so you can write a simple
sequence like this for printing:

JFreeReport report = ... (your favourite ReportCreation method here ...);

ReportPane reportPane = new ReportPane(report);
PrinterJob pj = PrinterJob.getPrinterJob();
pj.setPageable(reportPane);
if (pj.printDialog())
{
try
{
pj.print();
}
catch (PrinterException e)
{
showExceptionDialog("error.printfailed", e);
}
}

The pageformat is defined in the JFreeReport-object using the setDefaultPageFormat method. This pageformat is set by the xml-parser and defaults to the default-printers default-pageformat if not set in the <report> tag.

Have more fun,
said Thomas

Anonymous
09-20-2002, 11:52 AM
Great, it works, Thanks a lot.