So I keep getting this error:
THE ERROR: java.awt.print.PrinterException: Paper's imageable width is too small.
I was able to piece together a printing class based off of a lot of questions on s.o. It was working. Until it didn't. I reverted to my code from before the break and it still doesn't work. I have tried numerous answers on stack overflow on the Paper's imageable width is too small. Thus far nothing.
It doesn't matter what printer I try to send it to or what size paper. I can print it to a PDF and it prints exactly how I would want it. 1.125"w x 3.5"h in portrait.
public void printComponenet(){
PrinterJob pj = PrinterJob.getPrinterJob();
pj.setJobName(" Print Component ");
pj.setPrintable (new Printable() {
public int print(Graphics pg, PageFormat pf, int pageNum){
if (pageNum > 0){
return Printable.NO_SUCH_PAGE;
}
Graphics2D g2 = (Graphics2D) pg;
g2.rotate(Math.toRadians(90));
g2.translate(0,-81);
g2.translate((int)pf.getImageableX(), (int)pf.getImageableY());
jPanelPrintLabel.paint(g2);
return Printable.PAGE_EXISTS;
}
});
if (pj.printDialog() == false)
return;
try {
pj.print();
} catch (PrinterException ex) {
System.out.print(ex);
// handle exception
}
}