Hello
I've got a big problem when printing some labels to a printer from java.
The label printer is a Toshiba Tec B-SV4
I need to print some labels to the printer. The labels have a 4 by 4 inch size.
The first thing I do is select the printer:
PrinterJob printerJob = PrinterJob.getPrinterJob();
try {
printerJob.setPrintService(services[selectedService]);
} catch (PrinterException ex) {
ex.printStackTrace();
}
Then I pass some attributes:
PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
MediaSizeName mediaSizeName = MediaSize.findMedia(4,4,MediaPrintableArea.INCH);
System.out.println(mediaSizeName.toString());
printRequestAttributeSet.add(mediaSizeName);
printRequestAttributeSet.add(new MediaPrintableArea(0, 0, 288, 288,MediaPrintableArea.INCH));
I also set the page format:
PageFormat pf = new PageFormat();//pj.defaultPage();
Paper p = new Paper();
p.setSize(288,288); // about 4in x 4in
p.setImageableArea(0,0,288,288);
pf.setPaper(p);
printerJob.setPrintable(this,pf);
printerJob.setPrintable(this,printerJob.pageDialog(pf));
The problem comes when printing.
If I show the native print dialog to the user (WindowS), the correct paper size for the label is not selected.
Instead, if I show the cross-platform printDialog, the correct paper size doesn't appear in the options, the options shoud be "User, 2 x 4, 4 x 4, 4 x 6", instead, you just can select between "2 x 4 and 4 x 6".
In the native version, all options appear
Any suggestions?
ThanlYou