I am trying to use a label printer (EPSON TM-T88V to be specific), to spit out PNG images.
I can get it to print fine, except when I am printing an image dimensions (220
Add a MediaPrintableArea:
das.add(new MediaPrintableArea(0.05, 0.05, 0.05, 0.05, MediaPrintableArea.INCH));
This is the settings I use for printing on A4 paper with 10mm margin.
int width = Math.round(MediaSize.ISO.A4.getX(MediaSize.MM));
int height = Math.round(MediaSize.ISO.A4.getY(MediaSize.MM));
das.add(new MediaPrintableArea(10, 10, width-20, height-20, MediaPrintableArea.MM));
You can find the available paper sizes via:
PrintService printService = PrintServiceLookup.lookupDefaultPrintService();
Media[] res = (Media[]) printService.getSupportedAttributeValues(Media.class, null, null);
for (Media media : res) {
if (media instanceof MediaSizeName) {
MediaSizeName msn = (MediaSizeName) media;
MediaSize ms = MediaSize.getMediaSizeForName(msn);
float width = ms.getX(MediaSize.INCH);
float height = ms.getY(MediaSize.INCH);
System.out.println(media + ": width = " + width + "; height = " + height);
}
}
Once you've found the available MediaSizeName that most closely fits your paper size, simply add it in place of MediaSizeName.ISO_A7.