1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| public int print(Graphics graphics, PageFormat pageFormat, int page) throws PrinterException {
int retValue = Printable.NO_SUCH_PAGE;
if (page <= 0) {
double xLeft = pageFormat.getImageableX();
double yTop = pageFormat.getImageableY();
double width = pageFormat.getImageableWidth();
double height = pageFormat.getImageableHeight();
System.out.println("xLeft : " + xLeft + " yTop : " + yTop + " width : " + width + " height : " + height);
Graphics2D g2D = (Graphics2D) graphics;
g2D.translate((int) xLeft, (int) yTop);
Image img = Toolkit.getDefaultToolkit().getImage("out.jpg");
g2D.drawImage(img, 0, 0, null);
retValue = Printable.PAGE_EXISTS;
}
return retValue; |