Package com.lowagie.text.pdf

Examples of com.lowagie.text.pdf.PdfAction


   *            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

    }
   
    public static PdfAnnotation convertAnnotation(PdfWriter writer, Annotation annot, Rectangle defaultRect) throws IOException {
        switch(annot.annotationType()) {
           case Annotation.URL_NET:
               return new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction((URL) annot.attributes().get(Annotation.URL)));
           case Annotation.URL_AS_STRING:
               return new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction((String) annot.attributes().get(Annotation.FILE)));
           case Annotation.FILE_DEST:
               return new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction((String) annot.attributes().get(Annotation.FILE), (String) annot.attributes().get(Annotation.DESTINATION)));
           case Annotation.SCREEN:
               boolean sparams[] = (boolean[])annot.attributes().get(Annotation.PARAMETERS);
               String fname = (String) annot.attributes().get(Annotation.FILE);
               String mimetype = (String) annot.attributes().get(Annotation.MIMETYPE);
               PdfFileSpecification fs;
               if (sparams[0])
                   fs = PdfFileSpecification.fileEmbedded(writer, fname, fname, null);
               else
                   fs = PdfFileSpecification.fileExtern(writer, fname);
               PdfAnnotation ann = PdfAnnotation.createScreen(writer, new Rectangle(annot.llx(), annot.lly(), annot.urx(), annot.ury()),
                       fname, fs, mimetype, sparams[1]);
               return ann;
           case Annotation.FILE_PAGE:
               return new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction((String) annot.attributes().get(Annotation.FILE), ((Integer) annot.attributes().get(Annotation.PAGE)).intValue()));
           case Annotation.NAMED_DEST:
               return new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction(((Integer) annot.attributes().get(Annotation.NAMED)).intValue()));
           case Annotation.LAUNCH:
               return new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction((String) annot.attributes().get(Annotation.APPLICATION),(String) annot.attributes().get(Annotation.PARAMETERS),(String) annot.attributes().get(Annotation.OPERATION),(String) annot.attributes().get(Annotation.DEFAULTDIR)));
           default:
             return new PdfAnnotation(writer, defaultRect.getLeft(), defaultRect.getBottom(), defaultRect.getRight(), defaultRect.getTop(), new PdfString(annot.title(), PdfObject.TEXT_UNICODE), new PdfString(annot.content(), PdfObject.TEXT_UNICODE));
       }
   }
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

    }
   
    public static PdfAnnotation convertAnnotation(PdfWriter writer, Annotation annot, Rectangle defaultRect) throws IOException {
        switch(annot.annotationType()) {
           case Annotation.URL_NET:
               return new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction((URL) annot.attributes().get(Annotation.URL)));
           case Annotation.URL_AS_STRING:
               return new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction((String) annot.attributes().get(Annotation.FILE)));
           case Annotation.FILE_DEST:
               return new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction((String) annot.attributes().get(Annotation.FILE), (String) annot.attributes().get(Annotation.DESTINATION)));
           case Annotation.SCREEN:
               boolean sparams[] = (boolean[])annot.attributes().get(Annotation.PARAMETERS);
               String fname = (String) annot.attributes().get(Annotation.FILE);
               String mimetype = (String) annot.attributes().get(Annotation.MIMETYPE);
               PdfFileSpecification fs;
               if (sparams[0])
                   fs = PdfFileSpecification.fileEmbedded(writer, fname, fname, null);
               else
                   fs = PdfFileSpecification.fileExtern(writer, fname);
               PdfAnnotation ann = PdfAnnotation.createScreen(writer, new Rectangle(annot.llx(), annot.lly(), annot.urx(), annot.ury()),
                       fname, fs, mimetype, sparams[1]);
               return ann;
           case Annotation.FILE_PAGE:
               return new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction((String) annot.attributes().get(Annotation.FILE), ((Integer) annot.attributes().get(Annotation.PAGE)).intValue()));
           case Annotation.NAMED_DEST:
               return new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction(((Integer) annot.attributes().get(Annotation.NAMED)).intValue()));
           case Annotation.LAUNCH:
               return new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction((String) annot.attributes().get(Annotation.APPLICATION),(String) annot.attributes().get(Annotation.PARAMETERS),(String) annot.attributes().get(Annotation.OPERATION),(String) annot.attributes().get(Annotation.DEFAULTDIR)));
           default:
             return new PdfAnnotation(writer, defaultRect.getLeft(), defaultRect.getBottom(), defaultRect.getRight(), defaultRect.getTop(), new PdfString(annot.title(), PdfObject.TEXT_UNICODE), new PdfString(annot.content(), PdfObject.TEXT_UNICODE));
       }
   }
View Full Code Here

                    String anchor = uri.substring(1);
                    Box target = _sharedContext.getBoxById(anchor);
                    if (target != null) {
                        PdfDestination dest = createDestination(c, target);
                       
                        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;
                        }
                        PdfAnnotation annot = PdfAnnotation.createLink(
                                _writer, targetArea, PdfAnnotation.HIGHLIGHT_INVERT, action);
                        annot.setBorderStyle(new PdfBorderDictionary(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

            // we add some content
            document.add(new Paragraph("Outline action example"));
            // we add the outline
            PdfContentByte cb = writer.getDirectContent();
            PdfOutline root = cb.getRootOutline();
            PdfOutline links = new PdfOutline(root, new PdfAction("http://www.lowagie.com/iText/links.html"), "Useful links");
            links.setColor(new Color(0x00, 0x80, 0x80));
            links.setStyle(Font.BOLD);
            new PdfOutline(links, new PdfAction("http://www.lowagie.com/iText"), "Bruno's iText site");
            new PdfOutline(links, new PdfAction("http://itextpdf.sourceforge.net/"), "Paulo's iText site");
            new PdfOutline(links, new PdfAction("http://sourceforge.net/projects/itext/"), "iText @ SourceForge");
            PdfOutline other = new PdfOutline(root, new PdfDestination(PdfDestination.FIT), "other actions", false);
            other.setStyle(Font.ITALIC);
            new PdfOutline(other, new PdfAction("remote.pdf", 1), "Go to yhe first page of a remote file");
            new PdfOutline(other, new PdfAction("remote.pdf", "test"), "Go to a local destination in a remote file");
            new PdfOutline(other, PdfAction.javaScript("app.alert('Hello');\r", writer), "Say Hello");
           
            remote.add(new Paragraph("Some remote document"));
            remote.newPage();
            Paragraph p = new Paragraph("This paragraph contains a ");
View Full Code Here

            state.add("toggle");
            state.add(l1);
            state.add(l2);
            state.add(l3);
            state.add(l4);
            PdfAction action = PdfAction.setOCGstate(state, true);
            Chunk ck = new Chunk("Click here to toggle the layers", new Font(Font.HELVETICA, 18, Font.NORMAL, Color.yellow)).setBackground(Color.blue).setAction(action);
            ColumnText.showTextAligned(cb, Element.ALIGN_CENTER, new Phrase(ck), 250, 400, 0);
            cb.sanityCheck();
           
            // step 5: closing the document
View Full Code Here

      // step 3: we open the document
      document.open();
      // step 4: we add some content
      String application = args[0] + "notepad.exe";
      Paragraph p = new Paragraph(new Chunk("Click to open "
          + application).setAction(new PdfAction(application, null,
          null, null)));
      document.add(p);
    } catch (Exception de) {
      de.printStackTrace();
    }
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.