root.getMaxPageWidth(c, pagePaintingClearanceWidth),
root.getLastPage().getPaintingBottom() + PAGE_PAINTING_CLEARANCE_HEIGHT));
revalidate();
Graphics2D g = ((Java2DOutputDevice)c.getOutputDevice()).getGraphics();
Shape working = g.getClip();
List pages = root.getPages();
c.setPageCount(pages.size());
for (int i = 0; i < pages.size(); i++) {
PageBox page = (PageBox)pages.get(i);
c.setPage(i, page);
g.setClip(working);
Rectangle overall = page.getScreenPaintingBounds(c, pagePaintingClearanceWidth);
overall.x -= 1;
overall.y -= 1;
overall.width += 1;
overall.height += 1;
Rectangle bounds = new Rectangle(overall);
bounds.width += 1;
bounds.height += 1;
if (working.intersects(bounds)) {
page.paintBackground(c, pagePaintingClearanceWidth, Layer.PAGED_MODE_SCREEN);
page.paintMarginAreas(c, pagePaintingClearanceWidth, Layer.PAGED_MODE_SCREEN);
page.paintBorder(c, pagePaintingClearanceWidth, Layer.PAGED_MODE_SCREEN);
Color old = g.getColor();