MediaPrintableArea changed from JDK5 to JDK6

N

Nicola Talbot

Hi,

I'm getting different results for the printable area for different
versions of java (running on Linux 2.6.17-1.2142_FC4). The code below
just gets the printable area for A4 landscape.

Using java version "1.5.0_09", I get:

(6.35,6.35)->(197.3,284.3)mm

This area is centred on A4 landscape paper, which is what I expect.

Using java version "1.6.0_07", I get:

(12.7,12.7)->(197.203,284.339)mm

Since A4 landscape is (297mm x 210mm), this means that the printable
area goes slightly off the edge of the paper. It seems the offset has
been doubled and the area has (very slightly) increased. I searched
the bug database, but couldn't find anything that matched (although
it's possible I may have missed something). Has anyone else come
across this? Both examples were run using the same printer and printer
driver.

import java.awt.print.*;
import javax.print.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.*;

public class TestMediaPrintableArea
{
public static void main(String[] args)
{
HashPrintRequestAttributeSet aset
= new HashPrintRequestAttributeSet();

aset.add(MediaSizeName.ISO_A4);
aset.add(OrientationRequested.LANDSCAPE);

PrintService[] services = PrinterJob.lookupPrintServices();

if (services.length > 0)
{
MediaPrintableArea[] mpa = (MediaPrintableArea[])
services[0].getSupportedAttributeValues(
MediaPrintableArea.class,null,
aset);

for (int i = 0; i < mpa.length; i++)
{
System.out.println(mpa);
}
}
}
}

Regards
Nicola Talbot
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,480
Members
44,900
Latest member
Nell636132

Latest Threads

Top