PDA

View Full Version : Setup Page



Anonymous
08-19-2002, 06:51 AM
Hello,

I need to set a default pagesize for my reports (smaller upper and left border). I know how to change the page-properties in the preview, so there must be a possibillity somehow.
Changing the attributes height and width from the report doesn't seem to have any effect at all.
I bought the documentation and searched the forum but couldn't find a solution.
Can anyone help me?
Greetings.

Marc

Anonymous
08-19-2002, 10:13 AM
Hi,

those attributes were left overs and will be removed. They are ignored and the only way to give a default page format is to set it manually. The parser will never ever set a page format in its current state. ... another thing to fix ...

Have more fun,
said Thomas

Anonymous
08-19-2002, 11:31 AM
Hi,

do mean that the user has to set it via the gui? If there is any way to set
a deafult page format from within my java-program i'd be thankful for some more detailed information.

Thanks.
Marc

Anonymous
08-19-2002, 02:15 PM
Hi,

prepare your PageFormat and set it using FreeReport.setDefaultPageFormat(). This one is used as default for the PreviewPane. If your want to use a specific PageFormat for printing or saving to pdf, you'll have to supply your prepared PageFormat to the OutputTarget's constructors.

Have more fun,
said Thomas

Anonymous
08-20-2002, 05:46 AM
Thanks, that's what I was looking for. In case anyone else is interested,
here my code for setting up the european paper-fornat DIN A4:

Paper a4Paper = new Paper ();
PageFormat pageFormat = new PageFormat ();
// pageFormat.setOrientation (PageFormat.LANDSCAPE);
/*
* set size of paper sheet
* DIN A4 should be 8.26x11.69 inches
*/
double paperWidth = 8.26;
double paperHeight = 11.69;
a4Paper.setSize(paperWidth * 72.0, paperHeight * 72.0);

/*
* set the margins respectively the imageable area
*/
double leftMargin = 0.78; /* should be about 2cm */
double rightMargin = 0.78;
double topMargin = 0.08; // this is a very small topMargin
double bottomMargin = 0.78;

a4Paper.setImageableArea(leftMargin * 72.0, topMargin * 72.0,
(paperWidth - leftMargin - rightMargin)*72.0,
(paperHeight - topMargin - bottomMargin)*72.0);
/*
* create a PageFormat and associate the Paper with it.
*/
pageFormat = new java.awt.print.PageFormat();
pageFormat.setPaper(a4Paper);

report.setDefaultPageFormat(pageFormat);
PreviewFrame frame = new PreviewFrame(this.report);

frame.setToolbarFloatable(true);
frame.pack ();
RefineryUtilities.positionFrameRandomly(frame);
frame.setVisible(true);
frame.requestFocus();