List of usage examples for com.lowagie.text.pdf PdfAnnotation PdfAnnotation
public PdfAnnotation(PdfWriter writer, float llx, float lly, float urx, float ury, PdfAction action)
PdfAnnotation
of subtype link (Action). From source file:org.eclipse.birt.report.engine.emitter.pdf.PDFPage.java
License:Open Source License
private void createHyperlink(String hyperlink, String bookmark, String targetWindow, int type, float x, float y, float width, float height) { y = transformY(y, height);//from w w w . j a v a 2 s .c om writer.addAnnotation(new PdfAnnotation(writer, x, y, x + width, y + height, createPdfAction(hyperlink, bookmark, targetWindow, type))); }
From source file:org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.internal.PdfLogicalPageDrawable.java
License:Open Source License
protected boolean drawPdfScript(final RenderNode box) { final Object attribute = box.getAttributes().getAttribute(AttributeNames.Pdf.NAMESPACE, AttributeNames.Pdf.SCRIPT_ACTION); if (attribute == null) { return false; }//from w ww .j a va2s . com final String attributeText = String.valueOf(attribute); final PdfAction action = PdfAction.javaScript(attributeText, writer, false); final AffineTransform affineTransform = getGraphics().getTransform(); final float translateX = (float) affineTransform.getTranslateX(); final float leftX = translateX + (float) (StrictGeomUtility.toExternalValue(box.getX())); final float rightX = translateX + (float) (StrictGeomUtility.toExternalValue(box.getX() + box.getWidth())); final float lowerY = (float) (globalHeight - StrictGeomUtility.toExternalValue(box.getY() + box.getHeight())); final float upperY = (float) (globalHeight - StrictGeomUtility.toExternalValue(box.getY())); final PdfAnnotation annotation = new PdfAnnotation(writer, leftX, lowerY, rightX, upperY, action); writer.addAnnotation(annotation); return true; }
From source file:org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.internal.PdfLogicalPageDrawable.java
License:Open Source License
protected void drawHyperlink(final RenderNode box, final String target, final String window, final String title) { if (box.isNodeVisible(getDrawArea()) == false) { return;/* w ww .j a va 2s . c o m*/ } final PdfAction action = createActionForLink(target); final AffineTransform affineTransform = getGraphics().getTransform(); final float translateX = (float) affineTransform.getTranslateX(); final float leftX = translateX + (float) (StrictGeomUtility.toExternalValue(box.getX())); final float rightX = translateX + (float) (StrictGeomUtility.toExternalValue(box.getX() + box.getWidth())); final float lowerY = (float) (globalHeight - StrictGeomUtility.toExternalValue(box.getY() + box.getHeight())); final float upperY = (float) (globalHeight - StrictGeomUtility.toExternalValue(box.getY())); if (action != null) { final PdfAnnotation annotation = new PdfAnnotation(writer, leftX, lowerY, rightX, upperY, action); writer.addAnnotation(annotation); } else if (StringUtils.isEmpty(title) == false) { final Rectangle rect = new Rectangle(leftX, lowerY, rightX, upperY); final PdfAnnotation commentAnnotation = PdfAnnotation.createText(writer, rect, "Tooltip", title, false, null); commentAnnotation.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, writer.getDirectContent().createAppearance(rect.getWidth(), rect.getHeight())); writer.addAnnotation(commentAnnotation); } }
From source file:org.xhtmlrenderer.pdf.ITextOutputDevice.java
License:Open Source License
private void processLink(RenderingContext c, Box box) { Element elem = box.getElement(); if (elem != null) { NamespaceHandler handler = _sharedContext.getNamespaceHandler(); String uri = handler.getLinkUri(elem); if (uri != null) { if (uri.length() > 1 && uri.charAt(0) == '#') { String anchor = uri.substring(1); Box target = _sharedContext.getBoxById(anchor); if (target != null) { PdfDestination dest = createDestination(c, target); if (dest != null) { PdfAction action = new PdfAction(); if (!"".equals(handler.getAttributeValue(elem, "onclick"))) { action = PdfAction.javaScript(handler.getAttributeValue(elem, "onclick"), _writer); } else { action.put(PdfName.S, PdfName.GOTO); action.put(PdfName.D, dest); }// ww w. j a v a2s. c o m com.lowagie.text.Rectangle targetArea = checkLinkArea(c, box); if (targetArea == null) { return; } targetArea.setBorder(0); targetArea.setBorderWidth(0); PdfAnnotation annot = new PdfAnnotation(_writer, targetArea.getLeft(), targetArea.getBottom(), targetArea.getRight(), targetArea.getTop(), action); annot.put(PdfName.SUBTYPE, PdfName.LINK); annot.setBorderStyle(new PdfBorderDictionary(0.0f, 0)); annot.setBorder(new PdfBorderArray(0.0f, 0.0f, 0)); _writer.addAnnotation(annot); } } } else if (uri.indexOf("://") != -1) { PdfAction action = new PdfAction(uri); com.lowagie.text.Rectangle targetArea = checkLinkArea(c, box); if (targetArea == null) { return; } PdfAnnotation annot = new PdfAnnotation(_writer, targetArea.getLeft(), targetArea.getBottom(), targetArea.getRight(), targetArea.getTop(), action); annot.put(PdfName.SUBTYPE, PdfName.LINK); annot.setBorderStyle(new PdfBorderDictionary(0.0f, 0)); annot.setBorder(new PdfBorderArray(0.0f, 0.0f, 0)); _writer.addAnnotation(annot); } } } }