Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
public void printPages(Pageable printComponents) {
boolean doPrint = this.printerJob.printDialog();
if (doPrint) {
try {
this.printerJob.setPageable((Book) printComponents);
this.printerJob.print();
}
catch (Exception e) {
e.printStackTrace();
}
}
}
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException {
Graphics2D graphics2D = (Graphics2D) graphics;
double x = pageFormat.getImageableX();
double y = pageFormat.getImageableY();
double w = pageFormat.getImageableWidth();
double h = pageFormat.getImageableHeight();
double sx = w / this.getWidth();
double sy = h / this.getHeight();
graphics2D.translate(x, y);
//graphics2D.scale(sx, sy);
this.printAll(graphics2D);
if (pageIndex != 0) {
return Printable.NO_SUCH_PAGE;
}
else {
return Printable.PAGE_EXISTS;
}
}
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException {
Graphics2D graphics2D = (Graphics2D) graphics;
double x = pageFormat.getImageableX();
double y = pageFormat.getImageableY();
double w = pageFormat.getImageableWidth();
double h = pageFormat.getImageableHeight();
double sx = w / this.getWidth();
double sy = h / this.getHeight();
graphics2D.translate(x, y);
//graphics2D.scale(sx, sy);
this.printAll(graphics2D);
/*
if (pageIndex != 0) {
return Printable.NO_SUCH_PAGE;
}
else {
return Printable.PAGE_EXISTS;
}
*/
return Printable.PAGE_EXISTS;
}
public void printPages(Pageable printComponents) {
//Dies dem printerJob vor dem Aufruf des printDialog() setzen!
this.printerJob.setPageable((Book) printComponents);
if (this.printerJob.printDialog()) {
try {
this.printerJob.print();
}
catch (Exception e) {
e.printStackTrace();
}
}
}