Example usage for com.lowagie.text.pdf PdfAction javaScript

List of usage examples for com.lowagie.text.pdf PdfAction javaScript

Introduction

In this page you can find the example usage for com.lowagie.text.pdf PdfAction javaScript.

Prototype

public static PdfAction javaScript(String code, PdfWriter writer, boolean unicode) 

Source Link

Document

Creates a JavaScript action.

Usage

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  ww  w. jav a 2  s .c om

    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;
}