public int print(Graphics g, PageFormat format,
int pageIndex) throws PrinterException {
if (pageIndex >= pageStore.getPageCount()) {
return Printable.NO_SUCH_PAGE;
}
Page page = pageStore.getPage(pageIndex);
page.resolveForwards(formatter.getContext());
PageLayout layout = formatter.getPageLayout();
Rectangle2D rc = format == null
? layout.getDrawableArea(Unit.PT)
: layout.getDrawableArea(format);
page.draw((Graphics2D)g, rc.getX(), rc.getY(),
rc.getHeight());
return Printable.PAGE_EXISTS;
}
}, formatter.getPageFormat());
if (job.printDialog()) {