Package com.lowagie.text

Examples of com.lowagie.text.Paragraph


      }
      FactoryProperties.insertStyle(h, cprops);
      if (tag.equals(HtmlTags.ANCHOR)) {
        cprops.addToChain(tag, h);
        if (currentParagraph == null) {
          currentParagraph = new Paragraph();
        }
        stack.push(currentParagraph);
        currentParagraph = new Paragraph();
        return;
      }
      if (tag.equals(HtmlTags.NEWLINE)) {
        if (currentParagraph == null) {
          currentParagraph = new Paragraph();
        }
        currentParagraph.add(factoryProperties
            .createChunk("\n", cprops));
        return;
      }
      if (tag.equals(HtmlTags.HORIZONTALRULE)) {
        // Attempting to duplicate the behavior seen on Firefox with
        // http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_hr_test
        // where an initial break is only inserted when the preceding element doesn't
        // end with a break, but a trailing break is always inserted.
        boolean addLeadingBreak = true;
        if (currentParagraph == null) {
          currentParagraph = new Paragraph();
          addLeadingBreak = false;
        }
        if (addLeadingBreak) { // Not a new paragraph
          int numChunks = currentParagraph.getChunks().size();
          if (numChunks == 0 ||
View Full Code Here


        cprops.removeChain(tag);
        return;
      }
      if (tag.equals("a")) {
        if (currentParagraph == null) {
          currentParagraph = new Paragraph();
        }
        boolean skip = false;
        if (interfaceProps != null) {
          ALink i = (ALink) interfaceProps.get("alink_interface");
          if (i != null)
            skip = i.process(currentParagraph, cprops);
        }
        if (!skip) {
          String href = cprops.getProperty("href");
          if (href != null) {
            ArrayList chunks = currentParagraph.getChunks();
            int size = chunks.size();
            for (int k = 0; k < size; ++k) {
              Chunk ck = (Chunk) chunks.get(k);
              ck.setAnchor(href);
            }
          }
        }
        Paragraph tmp = (Paragraph) stack.pop();
        LwgPhrase tmp2 = new LwgPhrase();
        tmp2.add(currentParagraph);
        tmp.add(tmp2);
        currentParagraph = tmp;
        cprops.removeChain("a");
        return;
      }
      if (tag.equals("br")) {
View Full Code Here

                currentfont.pop();
                return;
            }
            case LwgElement.PARAGRAPH:
            {
                Paragraph paragraph = (Paragraph) element;
                styleAttributes = new Properties();
                if (paragraph.hasLeading()) styleAttributes.setProperty(Markup.CSS_KEY_LINEHEIGHT, paragraph.getTotalLeading() + "pt");
                // start tag
                addTabs(indent);
                writeStart(HtmlTags.DIV);
                writeMarkupAttributes(markup);
                String alignment = HtmlEncoder.getAlignment(paragraph.getAlignment());
                if (!"".equals(alignment)) {
                    write(HtmlTags.ALIGN, alignment);
                }
                write(paragraph.getFont(), styleAttributes);
                os.write(GT);
                currentfont.push(paragraph.getFont());
                // contents
                for (Iterator i = paragraph.iterator(); i.hasNext(); ) {
                    write((LwgElement)i.next(), indent + 1);
                }
                // end tag
                addTabs(indent);
                writeEnd(HtmlTags.DIV);
View Full Code Here

                            else
                                img.scaleToFit(width, height);
                    }
                    img.setAbsolutePosition(20, 20);
                        document.newPage();
                        document.add(new Paragraph(tiff_file + " - page " + (c + 1)));
                  }
                    cb.addImage(img);
                    System.out.println("Finished page " + (c + 1));
                }
            }
View Full Code Here

            TextElementArray current;
            try {
                current = (TextElementArray) stack.pop();
            } catch (EmptyStackException ese) {
              if (bf == null) {
                current = new Paragraph("", new LwgFont());
              }
              else {
                current = new Paragraph("", new LwgFont(this.bf));
              }
            }
            current.add(currentChunk);
            stack.push(current);
            currentChunk = null;
View Full Code Here

        }

        try {
            // titles of sections and chapters
            if (ElementTags.TITLE.equals(name)) {
                Paragraph current = (Paragraph) stack.pop();
                if (currentChunk != null) {
                    current.add(currentChunk);
                    currentChunk = null;
                }
                Section previous = (Section) stack.pop();
                previous.setTitle(current);
                stack.push(previous);
                return;
            }

            // all other endtags
            if (currentChunk != null) {
                TextElementArray current;
                try {
                    current = (TextElementArray) stack.pop();
                } catch (EmptyStackException ese) {
                    current = new Paragraph();
                }
                current.add(currentChunk);
                stack.push(current);
                currentChunk = null;
            }

            // chunks
View Full Code Here

            }
            BufferedReader in = new BufferedReader(new FileReader((File)getValue("srcfile")));
            PdfWriter.getInstance(document, new FileOutputStream((File)getValue("destfile")));
            document.open();
            while ((line = in.readLine()) != null) {
                document.add(new Paragraph(12, line, f));
            }
            document.close();
    } catch (Exception e) {
          JOptionPane.showMessageDialog(internalFrame,
                e.getMessage(),
View Full Code Here

        document.addKeywords((String)keywords);
      Object description = reader.getInfo().get("Subject");
      if (keywords != null)
        document.addSubject((String)description);
      document.open();
      Paragraph t;
      if (title == null)
        t = new Paragraph("Index for " + src.getName());
      else
        t = new Paragraph("Index for '" + title + "'");
      document.add(t);
      if (description != null) {
        Paragraph d = new Paragraph((String) description);
        document.add(d);
      }
      List<HashMap<String, Object>> list = SimpleBookmark.getBookmark(reader);
      if (list == null) {
        document.add(new Paragraph("This document has no bookmarks."));
      }
      else {
        for (HashMap<String, Object> c: list) {
          Chapter chapter = (Chapter)createBookmark(src.getName(), null, c);
          List<HashMap<String, Object>> kids = (List<HashMap<String, Object>>) c.get("Kids");
View Full Code Here

   * @param bookmark the bookmark that has the data for the line
   * @return a subsection of section
   */
  private static Section createBookmark(String pdf, Section section, HashMap<String, Object> bookmark) {
    Section s;
    Paragraph title = new Paragraph((String)bookmark.get("Title"));
    System.out.println((String)bookmark.get("Title"));
    String action = (String)bookmark.get("Action");
    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);
    }
    else {
View Full Code Here

           
            // step 3: we open the document
            document.open();
           
            // step 4:
            document.add(new Paragraph("The size of this page is 288x720 points."));
            document.add(new Paragraph("288pt / 72 points per inch = 4 inch"));
            document.add(new Paragraph("720pt / 72 points per inch = 10 inch"));
            document.add(new Paragraph("The size of this page is 4x10 inch."));
            document.add(new Paragraph("4 inch x 2.54 = 10.16 cm"));
            document.add(new Paragraph("10 inch x 2.54 = 25.4 cm"));
            document.add(new Paragraph("The size of this page is 10.16x25.4 cm."));
            document.add(new Paragraph("The left border is 36pt or 0.5 inch or 1.27 cm"));
            document.add(new Paragraph("The right border is 18pt or 0.25 inch or 0.63 cm."));
            document.add(new Paragraph("The top and bottom border are 72pt or 1 inch or 2.54 cm."));
        }
        catch(DocumentException de) {
            System.err.println(de.getMessage());
        }
        catch(IOException ioe) {
View Full Code Here

TOP

Related Classes of com.lowagie.text.Paragraph

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.