“PrinterException: Paper's imageable width is too small” I can see what's wrong, but how can I fix it?

StackOverflow https://stackoverflow.com/questions/10601620

  •  09-06-2021
  •  | 
  •  

Question

I'm getting this error when I try to print something for a specific label printer in my current college project:

java.awt.print.PrinterException: Paper's imageable width is too small.
    at sun.print.RasterPrinterJob.printPage(Unknown Source)
    at sun.print.RasterPrinterJob.print(Unknown Source)
    at sun.print.RasterPrinterJob.print(Unknown Source)
    at Printer.print(Printer.java:91)
    at Printer.<init>(Printer.java:43)
    at VisitorDBTest.main(VisitorDBTest.java:10)

But I cannot see the reason why. I have the exact label code for this particular printer, the label width and height are correct. I set the imageable size to the exact label size (in 1/72nd's of an inch), then I tried setting it smaller with no luck. This code works fine when I print to my normal inkjet on an A4 page. I only get the error when I try to print to the DYMO 450 label printer (using different Paper and PageFormat objects). Looking at the google results it appears I'm practically the only person in history to get this error.

EDIT: after printing the imageable width to screen I get these results:

Paper imageable width is 196.0
PageFormat imageable width is 151.0
PrinterJob imageable width is -65.0267716535433

It's my understanding that both the PageFormat takes it's imageable width from the Paper and the PrinterJob takes it's imageable width from the PageFormat. I'm obviously missing something here.

Was it helpful?

Solution

I had the same problem with Dymo 420P.

Try setting imageable area to the same size as paper and origin 0,0. Then after PrinterJob.printDialog(), call PrinterJob.validatePage() with your pageformat. It will return valid pageformat with proper imageable area.

OTHER TIPS

i solve it adding

    PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();

    aset.add(OrientationRequested.PORTRAIT);
    aset.add(MediaSizeName.INVOICE);


        job.print( aset);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top