Package com.lowagie.text

Examples of com.lowagie.text.Anchor


                    }
                    break;
                }
                case Element.ANCHOR: {
                  leadingCount++;
                    Anchor anchor = (Anchor) element;
                    String url = anchor.getReference();
                    leading = anchor.getLeading();
                    if (url != null) {
                        anchorAction = new PdfAction(url);
                    }
                    // we process the element
                    element.process(this);
View Full Code Here


                currentfont.pop();
                return;
            }
            case LwgElement.ANCHOR:
            {
                Anchor anchor = (Anchor) element;
                styleAttributes = new Properties();
                if (anchor.hasLeading()) styleAttributes.setProperty(Markup.CSS_KEY_LINEHEIGHT, anchor.getLeading() + "pt");
               
                // start tag
                addTabs(indent);
                writeStart(HtmlTags.ANCHOR);
                if (anchor.getName() != null) {
                    write(HtmlTags.NAME, anchor.getName());
                }
                if (anchor.getReference() != null) {
                    write(HtmlTags.REFERENCE, anchor.getReference());
                }
                writeMarkupAttributes(markup);
                write(anchor.getFont(), styleAttributes);
                os.write(GT);
                currentfont.push(anchor.getFont());
                // contents
                for (Iterator i = anchor.iterator(); i.hasNext(); ) {
                    write((LwgElement) i.next(), indent + 1);
                }
                // end tag
                addTabs(indent);
                writeEnd(HtmlTags.ANCHOR);
View Full Code Here

    if ("GoTo".equals(action)) {
      if (bookmark.get("Page") != null) {
        String page = (String)bookmark.get("Page");
        StringTokenizer tokens = new StringTokenizer(page);
        String token = tokens.nextToken();
        Anchor anchor = new Anchor(" page" + token);
        anchor.setReference(pdf + "#page=" + token);
        title.add(anchor);
      }
    }
    else if ("URI".equals(action)) {
      String url = (String)bookmark.get("URI");
      Anchor anchor = new Anchor(" Goto URL");
      anchor.setReference(url);
      title.add(anchor);
    }
    else if ("GoToR".equals(action)) {
      String remote = (String)bookmark.get("File");
      Anchor anchor = new Anchor(" goto " + remote);
      if (bookmark.get("Named") != null) {
        String named = (String)bookmark.get("Named");
        remote = remote + "#nameddest=" + named;
      }
      else if (bookmark.get("Page") != null) {
        String page = (String)bookmark.get("Page");
        StringTokenizer tokens = new StringTokenizer(page);
        String token = tokens.nextToken();
        anchor.add(new Chunk(" page " + token));
        remote = remote + "#page=" + token;
      }
      anchor.setReference(remote);
      title.add(anchor);
    }
    if (section == null) {
      s = new Chapter(title, 0);
    }
View Full Code Here

            p.add(new Chunk("How do you do?"));
            doc.add(p);
            p.setAlignment(LwgElement.ALIGN_RIGHT);
            doc.add(p);

            Anchor a = new Anchor("http://www.uni-klu.ac.at");
            a.setReference("http://www.uni-klu.ac.at");
            doc.add(a);

            LwgImage img = LwgImage.getInstance("pngnow.png");
            doc.add(new Chunk(img, 0, 0));
            doc.add(new Annotation("Mark", "This works!"));
View Full Code Here

                                   "The second one will be called when the HTML page is being unloaded,\n" +
                                   "for example when you go to another page.\n");
              document.add(phrase1);

            // add a HTML link <A HREF="...">
              Anchor anchor = new Anchor("Click here to execute the third JavaScript function.");
              anchor.setReference("JavaScript:sayHi()");
              document.add(anchor);

    } catch (Exception de) {
      de.printStackTrace();
    }
View Full Code Here

            // step 3: we open the document
            document.open();
           
            // step 4:
            Paragraph paragraph = new Paragraph("Please visit my ");
            Anchor anchor1 = new Anchor("website (external reference)", FontFactory.getFont(FontFactory.HELVETICA, 12, LwgFont.UNDERLINE, new Color(0, 0, 255)));
            anchor1.setReference("http://www.lowagie.com/iText/");
            anchor1.setName("top");
            paragraph.add(anchor1);
            paragraph.add(new Chunk(".\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"));
            document.add(paragraph);
            Anchor anchor2 = new Anchor("please jump to a local destination", FontFactory.getFont(FontFactory.HELVETICA, 12, LwgFont.NORMAL, new Color(0, 0, 255)));
            anchor2.setReference("#top");
            document.add(anchor2);
    } catch (DocumentException de) {
      System.err.println(de.getMessage());
    } catch (IOException ioe) {
      System.err.println(ioe.getMessage());
View Full Code Here

      // step 3: we open the document
      document.open();
      // step 4: we add a paragraph to the document
      document.add(new Paragraph("Hello World"));
      // we make references
      Anchor pdfRef = new Anchor("see Hello World in PDF.");
      pdfRef.setReference("./HelloWorldPdf.pdf");
      Anchor rtfRef = new Anchor("see Hello World in RTF.");
      rtfRef.setReference("./HelloWorldRtf.rtf");
     
      // we add the references, but only to the HTML page:
     
      pdf.pause();
      rtf.pause();
View Full Code Here

   * Creates an Anchor object based on a list of properties.
   * @param attributes
   * @return an Anchor
   */
  public static Anchor getAnchor(Properties attributes) {
    Anchor anchor = new Anchor(getPhrase(attributes));
    String value;
    value = attributes.getProperty(ElementTags.NAME);
    if (value != null) {
      anchor.setName(value);
    }
    value = (String) attributes.remove(ElementTags.REFERENCE);
    if (value != null) {
      anchor.setReference(value);
    }
    return anchor;
  }
View Full Code Here

                    }
                    break;
                }
                case LwgElement.ANCHOR: {
                  leadingCount++;
                    Anchor anchor = (Anchor) element;
                    String url = anchor.getReference();
                    leading = anchor.getLeading();
                    if (url != null) {
                        anchorAction = new PdfAction(url);
                    }
                    // we process the element
                    element.process(this);
View Full Code Here

    if ("GoTo".equals(action)) {
      if (bookmark.get("Page") != null) {
        String page = (String)bookmark.get("Page");
        StringTokenizer tokens = new StringTokenizer(page);
        String token = tokens.nextToken();
        Anchor anchor = new Anchor(" page" + token);
        anchor.setReference(pdf + "#page=" + token);
        title.add(anchor);
      }
    }
    else if ("URI".equals(action)) {
      String url = (String)bookmark.get("URI");
      Anchor anchor = new Anchor(" Goto URL");
      anchor.setReference(url);
      title.add(anchor);
    }
    else if ("GoToR".equals(action)) {
      String remote = (String)bookmark.get("File");
      Anchor anchor = new Anchor(" goto " + remote);
      if (bookmark.get("Named") != null) {
        String named = (String)bookmark.get("Named");
        remote = remote + "#nameddest=" + named;
      }
      else if (bookmark.get("Page") != null) {
        String page = (String)bookmark.get("Page");
        StringTokenizer tokens = new StringTokenizer(page);
        String token = tokens.nextToken();
        anchor.add(new Chunk(" page " + token));
        remote = remote + "#page=" + token;
      }
      anchor.setReference(remote);
      title.add(anchor);
    }
    if (section == null) {
      s = new Chapter(title, 0);
    }
View Full Code Here

TOP

Related Classes of com.lowagie.text.Anchor

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.