PDA

View Full Version : Various Issues



Anonymous
03-21-2002, 01:33 PM
After playing around some more, I've run into a few issues:

1) The report can not be saved as PDF in Landscape nor printed in landscape. Though preview shows landscape fine, both final outputs always revert to portrait.

2) If I want column headers, where do they go (Right now I'm thinking page header but see #3 for why I can't use it).

3) I can not get the page header to print anywhere but left justified. Multiple items just print on top of each other. The Alignment and X value are ignored.

4) A group has to exist. Without a group I get NullPointerExceptions. I can get around this with a group without a header or footer.

Thanks for any info,

Steve

Anonymous
03-21-2002, 08:32 PM
I was wrong about the group. I just have to have a groups tag set up on the xml. It can be empty.

Anonymous
03-22-2002, 11:03 AM
I'm not sure how (or if you even want) modified code sent back to you. But here's some changes I made to solve the landscape printing. I'm not sure if this is the JFreeReport way of how the code should look, but it does fix the problem.

In the PreviewFrame class:

to fix the pdf printing:

/**
* Presents a "Save As" dialog to the user, enabling him/her to save the report in PDF format.
*/
public void doSaveAs() throws IOException {

JFileChooser fileChooser = new JFileChooser();
ExtensionFileFilter filter = new ExtensionFileFilter("PDF Documents", ".pdf");
fileChooser.addChoosableFileFilter(filter);

int option = fileChooser.showSaveDialog(this);
if (option==JFileChooser.APPROVE_OPTION) {

PrinterJob pj = PrinterJob.getPrinterJob();
// PageFormat pf = pj.defaultPage();

// I commented out the above line and added the following line
PageFormat pf = reportPane.getOutputTarget().getPageFormat();

pf = pj.validatePage(pf);
OutputStream out = new FileOutputStream(fileChooser.getSelectedFile());
PDFOutputTarget target = new PDFOutputTarget(out, pf, true);
target.open("Title", "Author");
this.reportPane.getReport().processReport(target, true);
target.close();

}

}


to fix the landscape printing:

/**
* Prints the report.
*/
public void attemptPrint() {

PrinterJob pj = PrinterJob.getPrinterJob();

// pj.setPrintable(this.reportPane);

// I commented out the above line and added the following 2 lines
pj.validatePage(reportPane.getOutputTarget().getPageFormat());
pj.setPrintable(this.reportPane, reportPane.getOutputTarget().getPageFormat());

if (pj.printDialog()) {
try {
pj.print();
}
catch (PrinterException e) {
JOptionPane.showMessageDialog(this, e);
}
}

}


I also added the following method just so that I can start the report in landscape format. It is not needed to fix any problems:

/**
* Set the orientation of the report
*
* @param aOrient
*/
public void setOrientation(int aOrient) {
PrinterJob pj = PrinterJob.getPrinterJob();
PageFormat pf = reportPane.getOutputTarget().getPageFormat();
pf.setOrientation(aOrient);
reportPane.setPageFormat(pf);
validate();
}


Steve

Anonymous
03-22-2002, 01:25 PM
Hi Steve,

Thanks for the posts...I'm going to take a look at the issues you raised shortly.

Any changes you want to feed back into JFreeReport just e-mail me the classes you have changed with a short description of what you have done. I use JEdit's diff viewer to see exactly what has changed...

Or for small changes, posting here in the forum is fine.

Regards,

DG.

Anonymous
03-22-2002, 03:47 PM
Thanks. Also the issue with the page header seems to be limited to the Date Function. When I print just labels, it works OK. I keep looking at it to see if I can narrow it down more.

Steve

Anonymous
03-22-2002, 04:07 PM
I'm going to make one more comment regarding the page header. I wasn't even close to it being a bug. The date needs more specific attributes than for example the number functions. Once I added a width and an X pos it moved around.

So ignore this bug request (at least about the page header).

Sorry about that.

Steve