I'm putting up a printer dialog with
PrinterJob pj=PrinterJob.getPrinterJob();
pj.setPrintable(this);
if (pj.printDialog())
{
try{
pj.print();
}
catch (Exception e)
{
e.printStackTrace();
}
}
In the dialog, I'm clicking on the Properties...button, then selecting the
Landscape radio button.
In my print() method, I'm using PageFormat.getImageableHeight() and
PageFormat.getImageableWidth() to base my drawing calculations on.
But the width and height never seem to change whether I have selected
Portrait or Landscape.
So how do I tell the PrintFormat to switch to landscape mode? And why does
my choice in the Print dialog get ignored?
Thanks.
--
Rob Ross
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - -
To reply, simply remove what Mr. Charlton Heston might say.
Rob Ross wrote:
> Is there something special I have to know/do to get my paper to print in
> Landscape mode?
> I'm putting up a printer dialog with
> PrinterJob pj=PrinterJob.getPrinterJob();
>pj.setPrintable(this);
^^^^
pjob.setPrintable(this, pageFormat);
>if (pj.printDialog())
> {
> try{
> pj.print();
> }
> catch (Exception e)
> {
> e.printStackTrace();
> }
> }
> In the dialog, I'm clicking on the Properties...button, then selecting the
> Landscape radio button.
> In my print() method, I'm using PageFormat.getImageableHeight() and
> PageFormat.getImageableWidth() to base my drawing calculations on.
> But the width and height never seem to change whether I have selected
> Portrait or Landscape.
> So how do I tell the PrintFormat to switch to landscape mode? And why does
> my choice in the Print dialog get ignored?
This is related to your line:
>pj.setPrintable(this);
instead:
pjob.setPrintable(this, pageFormat);
Selecting the orientation can be done via the properties, however it
is usually done via the PageDialog, to get this you set in addition:
PageFormat pageFormat = pj.pageDialog(pj.defaultPage());
pjob.setPrintable(this, pageFormat);
To determine LANDSCAPE programatically you can set:
pageFormat.setOrientation(PageFormat.LANDSCAPE);
Linda
--
(=)
/ li...@jalice.ch - http://www.jalice.net
(=)
/ l.ra...@hswzfh.ch - http://www.hswzfh.ch
(=)
Rob Ross wrote:
> Is there something special I have to know/do to get my paper to print in
> Landscape mode?
> I'm putting up a printer dialog with
> PrinterJob pj=PrinterJob.getPrinterJob();
>pj.setPrintable(this);
^^^^
pj.setPrintable(this, pageFormat);
>if (pj.printDialog())
> {
> try{
> pj.print();
> }
> catch (Exception e)
> {
> e.printStackTrace();
> }
> }
> In the dialog, I'm clicking on the Properties...button, then selecting the
> Landscape radio button.
> In my print() method, I'm using PageFormat.getImageableHeight() and
> PageFormat.getImageableWidth() to base my drawing calculations on.
> But the width and height never seem to change whether I have selected
> Portrait or Landscape.
> So how do I tell the PrintFormat to switch to landscape mode? And why does
> my choice in the Print dialog get ignored?
This is related to your line:
>pj.setPrintable(this);
instead:
pj.setPrintable(this, pageFormat);
Selecting the orientation can be done via the properties, however it
is usually done via the PageDialog, to get this you set in addition:
PageFormat pageFormat = pj.pageDialog(pj.defaultPage());
pj.setPrintable(this, pageFormat);
> Is there something special I have to know/do to get my paper to print in
> Landscape mode?
>
> I'm putting up a printer dialog with
<snip>
> if (pj.printDialog())
<snip>
> In the dialog, I'm clicking on the Properties...button, then selecting the
> Landscape radio button.
I'm afraid this doesn't affect the pageFormat - something which caused no
end of hassle for users of my app - you'll need to use
PrinterJob.pageDialog(PageFormat) to change the orientation. Fortunately,
this is all sorted in J 1.4 (even without changing your code) since the
printDialog() dialog now has a setup button on it.
Simon.
Yes, I spent a day wrestling with that and ended up having to display both
the Page Setup dialog AND the print dialog when the user selects my
"Print..." menu item.
It's not very elegant! I'm glad this is fixed in 1.4....yet another reason
to migrate.
Thanks.
--
Rob Ross
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - -
To reply, simply remove what Mr. Charlton Heston might say.
"Simon Lewington" <simonle...@metacrawler.com> wrote in message
news:TCSF609...@tcosoftware.com...