The paper object creates a letter sized piece of paper with one inch margins. Is there any way to set different margins to allow a page designed to fit on letter to also print on A4 by reducing the margins? Or any other ideas? ------------------
There is a method called setImageableArea (shown below) public void setImageableArea(double x, double y, double width, double height) Sets the imageable area of this Paper. Parameters: x, y - the coordinates to which to set the upper-left corner of the imageable area of this Paper width - the value to which to set the width of the imageable area of this Paper height - the value to which to set the height of the imageable area of this Paper By changing x,y,width and height i was able to reduce the margine size. eg. in print() method Paper p=pageFormat.getPaper(); p.setImageableArea(x,y,width,height); pageFormat.setPaper(p);
Sorry - I realise that this is an old topic, but I found it when searching for the same problem, and just thought I'd add one small point that I found.
The values you get back for imageable area are in 1/72nds (1/72ths?) of an inch, but the values displayed in the Page Setup dialogue are (I assume) based on your regional settings and/or OS (for me, UK, Windows XP - I see millimetres). Fairly obvoius from looking at the API, but caused me a minor headache, so I thought I'd mention it.
Also, perhaps I'm being thick, but I was surprised that I had to get the Paper object seperately and use the pageFormat.setPaper(p) line. I expected to be able to just use pageFormat.getPaper().setImageableArea(...), but that didn't work.