Hi,
ich versuche gerade ein JEditorPane, welches mit html Code gefüllt ist zu drucken.
Allerdings druckt er immer und immer wieder nur die erste Seite aus...woran liegt das?
ich versuche gerade ein JEditorPane, welches mit html Code gefüllt ist zu drucken.
Allerdings druckt er immer und immer wieder nur die erste Seite aus...woran liegt das?
Java:
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException {
Font font = new Font("Serif", Font.PLAIN, 8);
FontMetrics metrics = graphics.getFontMetrics(font);
int lineHeight = metrics.getHeight();
double pageHeight = pageFormat.getImageableHeight();
int textLines = getHeight() / lineHeight;
int linesPerPage = ((int)pageHeight) / lineHeight;
int numBreaks = textLines / linesPerPage;
int[] pageBreaks = new int[numBreaks];
for(int b = 0; b < numBreaks; b++) {
pageBreaks[b] = (b + 1) * linesPerPage;
}
if(pageIndex > pageBreaks.length) {
return NO_SUCH_PAGE;
}
Graphics2D g2d = (Graphics2D)graphics;
g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
paint(g2d);
return PAGE_EXISTS;
}