Package com.lowagie.text.pdf

Examples of com.lowagie.text.pdf.PdfAction


          new FileOutputStream("NamedActions.pdf"));
      // step 3: we open the document
      document.open();
      // step 4: we add some content
      Paragraph p = new Paragraph(new Chunk("Click to print")
          .setAction(new PdfAction(PdfAction.PRINTDIALOG)));
      PdfPTable table = new PdfPTable(4);
      table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
      table.addCell(new Phrase(new Chunk("First Page")
          .setAction(new PdfAction(PdfAction.FIRSTPAGE))));
      table.addCell(new Phrase(new Chunk("Prev Page")
          .setAction(new PdfAction(PdfAction.PREVPAGE))));
      table.addCell(new Phrase(new Chunk("Next Page")
          .setAction(new PdfAction(PdfAction.NEXTPAGE))));
      table.addCell(new Phrase(new Chunk("Last Page")
          .setAction(new PdfAction(PdfAction.LASTPAGE))));
      for (int k = 1; k <= 10; ++k) {
        document.add(new Paragraph("This is page " + k));
        document.add(Chunk.NEWLINE);
        document.add(table);
        document.add(p);
View Full Code Here


      PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(
          "ChainedActions.pdf"));
      // step 3: we add Javascript as Metadata and we open the document       
      document.open();
      // step 4: we add some content
      PdfAction action = PdfAction.javaScript("app.alert('Welcome at my site');\r", writer);
      action.next(new PdfAction("http://www.lowagie.com/iText/"));
      Paragraph p = new Paragraph(new Chunk("Click to go to Bruno's site")
          .setAction(action));
      document.add(p);
    } catch (Exception de) {
      de.printStackTrace();
View Full Code Here

   *            the <CODE>URL</CODE> to link to
   * @return this <CODE>Chunk</CODE>
   */

  public Chunk setAnchor(URL url) {
    return setAttribute(ACTION, new PdfAction(url.toExternalForm()));
  }
View Full Code Here

   *            the url to link to
   * @return this <CODE>Chunk</CODE>
   */

  public Chunk setAnchor(String url) {
    return setAttribute(ACTION, new PdfAction(url));
  }
View Full Code Here

      PdfWriter.getInstance(remote, new FileOutputStream("remote.pdf"));
      // step 3:
      document.open();
      remote.open();
      // step 4: we add some content
      PdfAction action = PdfAction.gotoLocalPage(2, new PdfDestination(
          PdfDestination.XYZ, -1, 10000, 0), writer);
      writer.setOpenAction(action);
      document.add(new Paragraph("Page 1"));
      document.newPage();
      document.add(new Paragraph("Page 2"));
View Full Code Here

        for (int line = 0; line < heights.length - 1; ++line) {
            widths = width[line];
          // loop over the columns
            for (int col = 0; col < widths.length - 1; ++col) {
                if (line == 0 && col == 0)
                    cb.setAction(new PdfAction("http://www.lowagie.com/iText/"),
                        widths[col], heights[line + 1], widths[col + 1], heights[line]);
                cb.setRGBColorStrokeF((float)Math.random(), (float)Math.random(), (float)Math.random());
                // horizontal borderline
                cb.moveTo(widths[col], heights[line]);
                cb.lineTo(widths[col + 1], heights[line]);
View Full Code Here

        // loop over the rows
        for (int line = 0; line < heights.length - 1; ++line) {
          // loop over the columns
            for (int col = 0; col < widths.length - 1; ++col) {
                if (line == 0 && col == 0)
                    cb.setAction(new PdfAction("http://www.lowagie.com/iText/"),
                        widths[col], heights[line + 1], widths[col + 1], heights[line]);
                cb.setRGBColorStrokeF((float)Math.random(), (float)Math.random(), (float)Math.random());
                // horizontal borderline
                cb.moveTo(widths[col], heights[line]);
                cb.lineTo(widths[col + 1], heights[line]);
View Full Code Here

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

                            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;
                    }
View Full Code Here

TOP

Related Classes of com.lowagie.text.pdf.PdfAction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.