Bookmark(Bookmark parent, int x, int top, String title) { this(parent, new PdfDestination(PdfDestination.XYZ, x, top, 0), title); }
/** * Adds named destinations in bulk. * Valid keys and values of the map can be found in the map * that is created by SimpleNamedDestination. * @param map a map with strings as keys for the names, * and structured strings as values for the destinations * @param page_offset number of pages that has to be added to * the page numbers in the destinations (useful if you * use this method in combination with PdfCopy). * @since iText 5.0 */ public void addNamedDestinations(Map map, int page_offset) { Map.Entry entry; int page; String dest; PdfDestination destination; for (Iterator i = map.entrySet().iterator(); i.hasNext(); ) { entry = (Map.Entry)i.next(); dest = (String)entry.getValue(); page = Integer.parseInt(dest.substring(0, dest.indexOf(" "))); destination = new PdfDestination(dest.substring(dest.indexOf(" ") + 1)); addNamedDestination((String)entry.getKey(), page + page_offset, destination); } }
/** * Adds named destinations in bulk. * Valid keys and values of the map can be found in the map * that is created by SimpleNamedDestination. * @param map a map with strings as keys for the names, * and structured strings as values for the destinations * @param page_offset number of pages that has to be added to * the page numbers in the destinations (useful if you * use this method in combination with PdfCopy). * @since iText 5.0 */ public void addNamedDestinations(Map<String, String> map, int page_offset) { Map.Entry<String, String> entry; int page; String dest; PdfDestination destination; for (Iterator<Map.Entry<String, String>> i = map.entrySet().iterator(); i.hasNext(); ) { entry = i.next(); dest = entry.getValue(); page = Integer.parseInt(dest.substring(0, dest.indexOf(" "))); destination = new PdfDestination(dest.substring(dest.indexOf(" ") + 1)); addNamedDestination(entry.getKey(), page + page_offset, destination); } }
public void initializePage(PdfContentByte currentPage, float height) { _currentPage = currentPage; _pageHeight = height; _currentPage.saveState(); _transform = new AffineTransform(); _transform.scale(1.0d / _dotsPerPoint, 1.0d / _dotsPerPoint); _stroke = transformStroke(STROKE_ONE); _originalStroke = _stroke; _oldStroke = _stroke; setStrokeDiff(_stroke, null); if (_defaultDestination == null) { _defaultDestination = new PdfDestination(PdfDestination.FITH, height); _defaultDestination.addPage(_writer.getPageReference(1)); } _linkTargetAreas = new HashSet(); }
public void initializePage(PdfContentByte currentPage, float height) { _currentPage = currentPage; _pageHeight = height; _currentPage.saveState(); _transform = new AffineTransform(); _transform.scale(1.0d / _dotsPerPoint, 1.0d / _dotsPerPoint); _stroke = transformStroke(STROKE_ONE); _originalStroke = _stroke; _oldStroke = _stroke; setStrokeDiff(_stroke, null); if (_defaultDestination == null) { _defaultDestination = new PdfDestination(PdfDestination.FITH, height); _defaultDestination.addPage(_writer.getPageReference(1)); } _linkTargetAreas = new HashSet(); }
public void initializePage(PdfContentByte currentPage, float height) { _currentPage = currentPage; _pageHeight = height; _currentPage.saveState(); _transform = new AffineTransform(); _transform.scale(1.0d / _dotsPerPoint, 1.0d / _dotsPerPoint); _stroke = transformStroke(STROKE_ONE); _originalStroke = _stroke; _oldStroke = _stroke; setStrokeDiff(_stroke, null); if (_defaultDestination == null) { _defaultDestination = new PdfDestination(PdfDestination.FITH, height); _defaultDestination.addPage(_writer.getPageReference(1)); } _linkTargetAreas = new HashSet(); }
public void initializePage(PdfContentByte currentPage, float height) { _currentPage = currentPage; _pageHeight = height; _currentPage.saveState(); _transform = new AffineTransform(); _transform.scale(1.0d / _dotsPerPoint, 1.0d / _dotsPerPoint); _stroke = transformStroke(STROKE_ONE); _originalStroke = _stroke; _oldStroke = _stroke; setStrokeDiff(_stroke, null); if (_defaultDestination == null) { _defaultDestination = new PdfDestination(PdfDestination.FITH, height); _defaultDestination.addPage(_writer.getPageReference(1)); } _linkTargetAreas = new HashSet(); }
public void initializePage(PdfContentByte currentPage, float height) { _currentPage = currentPage; _pageHeight = height; _currentPage.saveState(); _transform = new AffineTransform(); _transform.scale(1.0d / _dotsPerPoint, 1.0d / _dotsPerPoint); _stroke = transformStroke(STROKE_ONE); _originalStroke = _stroke; _oldStroke = _stroke; setStrokeDiff(_stroke, null); if (_defaultDestination == null) { _defaultDestination = new PdfDestination(PdfDestination.FITH, height); _defaultDestination.addPage(_writer.getPageReference(1)); } _linkTargetAreas = new HashSet(); }
protected void drawBookmark( final RenderNode box, final String bookmark ) { if ( box.isNodeVisible( getDrawArea() ) == false ) { return; } final PdfOutline root = writer.getDirectContent().getRootOutline(); final AffineTransform affineTransform = getGraphics().getTransform(); final float translateX = (float) affineTransform.getTranslateX(); final float upperY = translateX + (float) ( globalHeight - StrictGeomUtility.toExternalValue( box.getY() ) ); final float leftX = (float) ( StrictGeomUtility.toExternalValue( box.getX() ) ); final PdfDestination dest = new PdfDestination( PdfDestination.FIT, leftX, upperY, 0 ); new PdfOutline( root, dest, bookmark ); // destination will always point to the 'current' page // todo: Make this a hierarchy .. }
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; 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()); }
protected void drawAnchor( final RenderNode content ) { if ( content.isNodeVisible( getDrawArea() ) == false ) { return; } final String anchorName = (String) content.getStyleSheet().getStyleProperty( ElementStyleKeys.ANCHOR_NAME ); if ( anchorName == null ) { return; } final AffineTransform affineTransform = getGraphics().getTransform(); final float translateX = (float) affineTransform.getTranslateX(); final float upperY = translateX + (float) ( globalHeight - StrictGeomUtility.toExternalValue( content.getY() ) ); final float leftX = (float) ( StrictGeomUtility.toExternalValue( content.getX() ) ); final PdfDestination dest = new PdfDestination( PdfDestination.FIT, leftX, upperY, 0 ); writer.getDirectContent().localDestination( anchorName, dest ); }
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 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; }