Answer the question
In order to leave comments, you need to log in
How to print from Java with more than 72dpi?
Good afternoon.
It is necessary to print invoices from java to a thermal printer. The maximum printer resolution is 203 dpi. When printing a square with a size of 72x72px, a square with an edge of 1 inch is obtained, from this I conclude that it prints with a resolution of 72dpi. I tried to use the following code in the formation of PrinterJob, but to no avail. If someone came across, please advise what to do?
HashPrintRequestAttributeSet attributeSet = new HashPrintRequestAttributeSet();
attributeSet.add(PrintQuality.HIGH);
attributeSet.add(new PrinterResolution(203,203,PrinterResolution.DPI));
job.print(attributeSet);
Answer the question
In order to leave comments, you need to log in
Maybe DPI 72 is specified in the properties of the printed image? This is done so that the image has the same size on different printing devices.
if you draw on canvas yourself, you can scale the Graphics:
@Override
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException, NotFitOnPageException {
Graphics2D g = (Graphics2D) graphics;
double s = 72.0 / 203;
g.scale(s, s);
...
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question