public synchronized Layer getRootLayer() { return getRootBox() == null ? null : getRootBox().getLayer(); }
public Layer getRootLayer() { return getRootBox() == null ? null : getRootBox().getLayer(); }
public synchronized Layer getRootLayer() { return getRootBox() == null ? null : getRootBox().getLayer(); }
private void writeBookmark(RenderingContext c, Box root, PdfOutline parent, Bookmark bookmark) { String href = bookmark.getHRef(); PdfDestination target = null; if (href.length() > 0 && href.charAt(0) == '#') { Box box = _sharedContext.getBoxById(href.substring(1)); if (box != null) { PageBox page = root.getLayer().getPage(c, getPageRefY(box)); int distanceFromTop = page.getMarginBorderPadding(c, CalculatedStyle.TOP); distanceFromTop += box.getAbsY() - page.getTop(); target = new PdfDestination(PdfDestination.XYZ, 0, normalizeY(distanceFromTop / _dotsPerPoint), 0); target.addPage(_writer.getPageReference(_startPageNo + page.getPageNo()+1)); } } if (target == null) { target = _defaultDestination; } PdfOutline outline = new PdfOutline(parent, target, bookmark.getName()); writeBookmarks(c, root, outline, bookmark.getChildren()); }
private void writeBookmark(RenderingContext c, Box root, PdfOutline parent, Bookmark bookmark) { String href = bookmark.getHRef(); PdfDestination target = null; Box box = bookmark.getBox(); if (href.length() > 0 && href.charAt(0) == '#') { box = _sharedContext.getBoxById(href.substring(1)); } if (box != null) { PageBox page = root.getLayer().getPage(c, getPageRefY(box)); int distanceFromTop = page.getMarginBorderPadding(c, CalculatedStyle.TOP); distanceFromTop += box.getAbsY() - page.getTop(); target = new PdfDestination(PdfDestination.XYZ, 0, normalizeY(distanceFromTop / _dotsPerPoint), 0); target.addPage(_writer.getPageReference(_startPageNo + page.getPageNo() + 1)); } if (target == null) { target = _defaultDestination; } PdfOutline outline = new PdfOutline(parent, target, bookmark.getName()); writeBookmarks(c, root, outline, bookmark.getChildren()); }
private PdfDestination createDestination(RenderingContext c, Box box) { PdfDestination result = null; PageBox page = _root.getLayer().getPage(c, getPageRefY(box)); if (page != null) { int distanceFromTop = page.getMarginBorderPadding(c, CalculatedStyle.TOP); distanceFromTop += box.getAbsY() + box.getMargin(c).top() - page.getTop(); result = new PdfDestination(PdfDestination.XYZ, 0, page.getHeight(c) / _dotsPerPoint - distanceFromTop / _dotsPerPoint, 0); result.addPage(_writer.getPageReference(_startPageNo + page.getPageNo() + 1)); } return result; }
private PdfDestination createDestination(RenderingContext c, Box box) { PdfDestination result = null; PageBox page = _root.getLayer().getPage(c, getPageRefY(box)); if (page != null) { int distanceFromTop = page.getMarginBorderPadding(c, CalculatedStyle.TOP); distanceFromTop += box.getAbsY() + box.getMargin(c).top() - page.getTop(); result = new PdfDestination(PdfDestination.XYZ, 0, page.getHeight(c) / _dotsPerPoint - distanceFromTop / _dotsPerPoint, 0); result.addPage(_writer.getPageReference(_startPageNo + page.getPageNo() + 1)); } return result; }
private PdfDestination createDestination(RenderingContext c, Box box) { PdfDestination result; PageBox page = _root.getLayer().getPage(c, getPageRefY(box)); int distanceFromTop = page.getMarginBorderPadding(c, CalculatedStyle.TOP); distanceFromTop += box.getAbsY() + box.getMargin(c).top() - page.getTop(); result = new PdfDestination(PdfDestination.XYZ, 0, page.getHeight(c) / _dotsPerPoint - distanceFromTop / _dotsPerPoint, 0); result.addPage(_writer.getPageReference(_startPageNo + page.getPageNo() + 1)); return result; }
private PdfDestination createDestination(RenderingContext c, Box box) { PdfDestination result; PageBox page = _root.getLayer().getPage(c, getPageRefY(box)); int distanceFromTop = page.getMarginBorderPadding(c, CalculatedStyle.TOP); distanceFromTop += box.getAbsY() + box.getMargin(c).top() - page.getTop(); result = new PdfDestination( PdfDestination.XYZ, 0, page.getHeight(c) / _dotsPerPoint - distanceFromTop / _dotsPerPoint, 0); result.addPage(_writer.getPageReference(_startPageNo + page.getPageNo()+1)); return result; }
private PdfDestination createDestination(RenderingContext c, Box box) { PdfDestination result; PageBox page = _root.getLayer().getPage(c, getPageRefY(box)); int distanceFromTop = page.getMarginBorderPadding(c, CalculatedStyle.TOP); distanceFromTop += box.getAbsY() + box.getMargin(c).top() - page.getTop(); result = new PdfDestination( PdfDestination.XYZ, 0, page.getHeight(c) / _dotsPerPoint - distanceFromTop / _dotsPerPoint, 0); result.addPage(_writer.getPageReference(_startPageNo + page.getPageNo()+1)); return result; }
public RenderingContext newRenderingContext(Graphics2D g) { XRLog.layout(Level.FINEST, "new context begin"); getSharedContext().setCanvas(this); XRLog.layout(Level.FINEST, "new context end"); RenderingContext result = getSharedContext().newRenderingContextInstance(); result.setFontContext(new Java2DFontContext(g)); result.setOutputDevice(new Java2DOutputDevice(g)); getSharedContext().getTextRenderer().setup(result.getFontContext()); if (rootBox != null) { result.setRootLayer(rootBox.getLayer()); } return result; }
public RenderingContext newRenderingContext(Graphics2D g) { XRLog.layout(Level.FINEST, "new context begin"); getSharedContext().setCanvas(this); XRLog.layout(Level.FINEST, "new context end"); RenderingContext result = getSharedContext().newRenderingContextInstance(); result.setFontContext(new Java2DFontContext(g)); result.setOutputDevice(new Java2DOutputDevice(g)); getSharedContext().getTextRenderer().setup(result.getFontContext()); final Box rb = getRootBox(); if (rb != null) { result.setRootLayer(rb.getLayer()); } return result; }
private PagePosition calcPDFPagePosition(CssContext c, String id, Box box) { PageBox page = _root.getLayer().getLastPage(c, box); if (page == null) { return null; } float x = box.getAbsX() + page.getMarginBorderPadding(c, CalculatedStyle.LEFT); float y = (page.getBottom() - (box.getAbsY() + box.getHeight())) + page.getMarginBorderPadding(c, CalculatedStyle.BOTTOM); x /= _dotsPerPoint; y /= _dotsPerPoint; PagePosition result = new PagePosition(); result.setId(id); result.setPageNo(page.getPageNo()); result.setX(x); result.setY(y); result.setWidth(box.getEffectiveWidth() / _dotsPerPoint); result.setHeight(box.getHeight() / _dotsPerPoint); return result; } }
private PagePosition calcPDFPagePosition(CssContext c, String id, Box box) { PageBox page = _root.getLayer().getLastPage(c, box); if (page == null) { return null; } float x = box.getAbsX() + page.getMarginBorderPadding(c, CalculatedStyle.LEFT); float y = (page.getBottom() - (box.getAbsY() + box.getHeight())) + page.getMarginBorderPadding(c, CalculatedStyle.BOTTOM); x /= _dotsPerPoint; y /= _dotsPerPoint; PagePosition result = new PagePosition(); result.setId(id); result.setPageNo(page.getPageNo()); result.setX(x); result.setY(y); result.setWidth(box.getEffectiveWidth() / _dotsPerPoint); result.setHeight(box.getHeight() / _dotsPerPoint); return result; } }
public com.lowagie.text.Rectangle createTargetArea(RenderingContext c, Box box) { PageBox current = c.getPage(); boolean inCurrentPage = box.getAbsY() > current.getTop() && box.getAbsY() < current.getBottom(); if (inCurrentPage || box.isContainedInMarginBox()) { return createLocalTargetArea(c, box); } else { Rectangle bounds = box.getContentAreaEdge(box.getAbsX(), box.getAbsY(), c); PageBox page = _root.getLayer().getPage(c, bounds.y); float bottom = getDeviceLength(page.getBottom() - (bounds.y + bounds.height) + page.getMarginBorderPadding(c, CalculatedStyle.BOTTOM)); float left = getDeviceLength(page.getMarginBorderPadding(c, CalculatedStyle.LEFT) + bounds.x); com.lowagie.text.Rectangle result = new com.lowagie.text.Rectangle(left, bottom, left + getDeviceLength(bounds.width), bottom + getDeviceLength(bounds.height)); return result; } }
private PagePosition calcPDFPagePosition(CssContext c, String id, Box box) { PageBox page = _root.getLayer().getLastPage(c, box); if (page == null) { return null; } float x = box.getAbsX() + page.getMarginBorderPadding(c, CalculatedStyle.LEFT); float y = (page.getBottom() - (box.getAbsY() + box.getHeight())) + page.getMarginBorderPadding(c, CalculatedStyle.BOTTOM); x /= _dotsPerPoint; y /= _dotsPerPoint; PagePosition result = new PagePosition(); result.setId(id); result.setPageNo(page.getPageNo()); result.setX(x); result.setY(y); result.setWidth(box.getEffectiveWidth() / _dotsPerPoint); result.setHeight(box.getHeight() / _dotsPerPoint); return result; } }
private PagePosition calcPDFPagePosition(CssContext c, String id, Box box) { PageBox page = _root.getLayer().getLastPage(c, box); if (page == null) { return null; } float x = box.getAbsX() + page.getMarginBorderPadding(c, CalculatedStyle.LEFT); float y = (page.getBottom() - (box.getAbsY() + box.getHeight())) + page.getMarginBorderPadding(c, CalculatedStyle.BOTTOM); x /= _dotsPerPoint; y /= _dotsPerPoint; PagePosition result = new PagePosition(); result.setId(id); result.setPageNo(page.getPageNo()); result.setX(x); result.setY(y); result.setWidth(box.getEffectiveWidth() / _dotsPerPoint); result.setHeight(box.getHeight() / _dotsPerPoint); return result; } }
public com.lowagie.text.Rectangle createTargetArea(RenderingContext c, Box box) { PageBox current = c.getPage(); boolean inCurrentPage = box.getAbsY() > current.getTop() && box.getAbsY() < current.getBottom(); if (inCurrentPage || box.isContainedInMarginBox()) { return createLocalTargetArea(c, box); } else { Rectangle bounds = box.getContentAreaEdge(box.getAbsX(), box.getAbsY(), c); PageBox page = _root.getLayer().getPage(c, bounds.y); float bottom = getDeviceLength(page.getBottom() - (bounds.y + bounds.height) + page.getMarginBorderPadding(c, CalculatedStyle.BOTTOM)); float left = getDeviceLength(page.getMarginBorderPadding(c, CalculatedStyle.LEFT) + bounds.x); com.lowagie.text.Rectangle result = new com.lowagie.text.Rectangle(left, bottom, left + getDeviceLength(bounds.width), bottom + getDeviceLength(bounds.height)); return result; } }
public com.itextpdf.text.Rectangle createTargetArea(RenderingContext c, Box box) { PageBox current = c.getPage(); boolean inCurrentPage = box.getAbsY() > current.getTop() && box.getAbsY() < current.getBottom(); if (inCurrentPage || box.isContainedInMarginBox()) { return createLocalTargetArea(c, box); } else { Rectangle bounds = box.getContentAreaEdge(box.getAbsX(), box.getAbsY(), c); PageBox page = _root.getLayer().getPage(c, bounds.y); float bottom = getDeviceLength(page.getBottom() - (bounds.y + bounds.height) + page.getMarginBorderPadding(c, CalculatedStyle.BOTTOM)); float left = getDeviceLength(page.getMarginBorderPadding(c, CalculatedStyle.LEFT) + bounds.x); com.itextpdf.text.Rectangle result = new com.itextpdf.text.Rectangle(left, bottom, left + getDeviceLength(bounds.width), bottom + getDeviceLength(bounds.height)); return result; } }
public com.lowagie.text.Rectangle createTargetArea(RenderingContext c, Box box) { PageBox current = c.getPage(); boolean inCurrentPage = box.getAbsY() > current.getTop() && box.getAbsY() < current.getBottom(); if (inCurrentPage || box.isContainedInMarginBox()) { return createLocalTargetArea(c, box); } else { Rectangle bounds = box.getContentAreaEdge(box.getAbsX(), box.getAbsY(), c); PageBox page = _root.getLayer().getPage(c, bounds.y); float bottom = getDeviceLength(page.getBottom() - (bounds.y + bounds.height) + page.getMarginBorderPadding(c, CalculatedStyle.BOTTOM)); float left = getDeviceLength(page.getMarginBorderPadding(c, CalculatedStyle.LEFT) + bounds.x); com.lowagie.text.Rectangle result = new com.lowagie.text.Rectangle( left, bottom, left + getDeviceLength(bounds.width), bottom + getDeviceLength(bounds.height)); return result; } }