I have a problem about the measurements of the paper that my Brother QL-800 printer has with a width of 62mm. and undefined height, since the paper is continuous so that the user can put the necessary measures.
I am creating an application in java and I cannot set height measurements less than 62mm. (which correspond to the width), although it is possible to set more than 62mm.
This is my code:
PrinterJob job = PrinterJob.getPrinterJob();
PageFormat pf = job.defaultPage();
Paper paper = new Paper();
paper.setSize(175.748031496, 175.748031496);
paper.setImageableArea(0, 0, 175.748031496, 175.748031496);
pf.setPaper(paper);
job.setPrintable(new ObjetoDeImpresion(), pf);
job.setJobName("nombre_de_impresion");
try {
job.print();
} catch (PrinterException e) {
e.printStackTrace();
}
The measure 175.748031496
is points and corresponds to 62mm
.
This is the object to print:
public class ObjetoDeImpresion implements Printable {
public ObjetoDeImpresion() {
}
@Override
public int print(Graphics g, PageFormat f, int i) throws PrinterException {
Graphics2D g2 = (Graphics2D) g;
switch (i) {
case 0:
g2.drawRect(30, 50, 80, 20);
g2.drawLine(0, 28, 130, 28);
return PAGE_EXISTS;
default:
return NO_SUCH_PAGE; // No other pages
} //To change body of generated methods, choose Tools | Templates.
}
}
I think the printer is detecting as if its height is also 62mm. since the paper at the top is continuous.
What I can do?
Try adding PrintRequest to change the printer attributes:
you can put it this way: