Package com.lowagie.text

Examples of com.lowagie.text.Chunk


      document.open();
      // step 4:
      String s = "quick brown fox jumps over the lazy dog";
      StringTokenizer st = new StringTokenizer(s, " ");
      float textrise = 6.0f;
      Chunk c;
      while (st.hasMoreTokens()) {
        c = new Chunk(st.nextToken());
        c.setTextRise(textrise);
        c.setUnderline(new Color(0xC0, 0xC0, 0xC0), 0.2f, 0.0f, 0.0f, 0.0f, PdfContentByte.LINE_CAP_BUTT);
        document.add(c);
        textrise -= 2.0f;
      }
    } catch (DocumentException de) {
      System.err.println(de.getMessage());
View Full Code Here


           
            // step 4:
           
            // high level
            Paragraph p = new Paragraph();
            for (int i = 0; i < 100; i++) p.add(new Chunk("Blah blah blah blah blah. "));
            document.add(p);
            LwgImage img = LwgImage.getInstance("hitchcock.png");
            img.setAbsolutePosition(100, 500);
            document.add(img);
           
View Full Code Here

   * Creates a Chunk object based on a list of properties.
   * @param attributes
   * @return a Chunk
   */
  public static Chunk getChunk(Properties attributes) {
    Chunk chunk = new Chunk();

    chunk.setFont(FontFactory.getFont(attributes));
    String value;

    value = attributes.getProperty(ElementTags.ITEXT);
    if (value != null) {
      chunk.append(value);
    }
    value = attributes.getProperty(ElementTags.LOCALGOTO);
    if (value != null) {
      chunk.setLocalGoto(value);
    }
    value = attributes.getProperty(ElementTags.REMOTEGOTO);
    if (value != null) {
      String page = attributes.getProperty(ElementTags.PAGE);
      if (page != null) {
        chunk.setRemoteGoto(value, Integer.parseInt(page));
      } else {
        String destination = attributes
            .getProperty(ElementTags.DESTINATION);
        if (destination != null) {
          chunk.setRemoteGoto(value, destination);
        }
      }
    }
    value = attributes.getProperty(ElementTags.LOCALDESTINATION);
    if (value != null) {
      chunk.setLocalDestination(value);
    }
    value = attributes.getProperty(ElementTags.SUBSUPSCRIPT);
    if (value != null) {
      chunk.setTextRise(Float.parseFloat(value + "f"));
    }
    value = attributes.getProperty(Markup.CSS_KEY_VERTICALALIGN);
    if (value != null && value.endsWith("%")) {
      float p = Float.parseFloat(value.substring(0, value.length() - 1)
          + "f") / 100f;
      chunk.setTextRise(p * chunk.getFont().getSize());
    }
    value = attributes.getProperty(ElementTags.GENERICTAG);
    if (value != null) {
      chunk.setGenericTag(value);
    }
    value = attributes.getProperty(ElementTags.BACKGROUNDCOLOR);
    if (value != null) {
      chunk.setBackground(Markup.decodeColor(value));
    }
    return chunk;
  }
View Full Code Here

          new FileOutputStream("Lines.pdf"));

      // step 3: we open the document
      document.open();
      // step 4:
      Chunk underlined = new Chunk("underlined");
      underlined.setUnderline(0.2f, -2f);
      Paragraph p = new Paragraph("The following chunk is ");
      p.add(underlined);
      document.add(p);
      Chunk strikethru = new Chunk("strike through example");
      strikethru.setUnderline(0.5f, 3f)
      document.add(strikethru);
      document.add(Chunk.NEWLINE);
      document.add(Chunk.NEWLINE);
      document.add(Chunk.NEWLINE);
      Chunk c;
      c = new Chunk("Multiple lines");
      c.setUnderline(new Color(0xFF, 0x00, 0x00), 0.0f, 0.3f, 0.0f, 0.4f, PdfContentByte.LINE_CAP_ROUND);
      c.setUnderline(new Color(0x00, 0xFF, 0x00), 5.0f, 0.0f, 0.0f, -0.5f, PdfContentByte.LINE_CAP_PROJECTING_SQUARE);
      c.setUnderline(new Color(0x00, 0x00, 0xFF), 0.0f, 0.2f, 15.0f, 0.0f, PdfContentByte.LINE_CAP_BUTT);
      document.add(c);
      document.add(Chunk.NEWLINE);
      document.add(Chunk.NEWLINE);
      document.add(Chunk.NEWLINE);
      c = new Chunk("Multiple lines", FontFactory.getFont(FontFactory.HELVETICA, 24));
      c.setUnderline(new Color(0xFF, 0x00, 0x00), 0.0f, 0.3f, 0.0f, 0.4f, PdfContentByte.LINE_CAP_ROUND);
      c.setUnderline(new Color(0x00, 0xFF, 0x00), 5.0f, 0.0f, 0.0f, -0.5f, PdfContentByte.LINE_CAP_PROJECTING_SQUARE);
      c.setUnderline(new Color(0x00, 0x00, 0xFF), 0.0f, 0.2f, 15.0f, 0.0f, PdfContentByte.LINE_CAP_BUTT);
      document.add(c);
    } catch (DocumentException de) {
      System.err.println(de.getMessage());
    } catch (IOException ioe) {
      System.err.println(ioe.getMessage());
View Full Code Here

      phrase.setLeading(Markup.parseLength(value,
          Markup.DEFAULT_FONT_SIZE));
    }
    value = attributes.getProperty(ElementTags.ITEXT);
    if (value != null) {
      Chunk chunk = new Chunk(value);
      if ((value = attributes.getProperty(ElementTags.GENERICTAG)) != null) {
        chunk.setGenericTag(value);
      }
      phrase.add(chunk);
    }
    return phrase;
  }
View Full Code Here

    }

    value = attributes.getProperty(ElementTags.LISTSYMBOL);
    if (value != null) {
      list
          .setListSymbol(new Chunk(value, FontFactory
              .getFont(attributes)));
    }

    value = attributes.getProperty(ElementTags.INDENTATIONLEFT);
    if (value != null) {
View Full Code Here

            fonts[10] = FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, LwgFont.ITALIC);
            fonts[11] = FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, LwgFont.BOLD | LwgFont.ITALIC);
            fonts[12] = FontFactory.getFont(FontFactory.SYMBOL, 12, LwgFont.NORMAL);
            fonts[13] = FontFactory.getFont(FontFactory.ZAPFDINGBATS, 12, LwgFont.NORMAL);
            for (int i = 0; i < 14; i++) {
                Chunk chunk = new Chunk("This is font ", fonts[i]);
                Paragraph p = new Paragraph(chunk);
                p.add(new LwgPhrase(new Chunk(f[i], fonts[i]).setGenericTag(f[i])));
                document.add(p);
                if (i % 4 == 3) {
                    document.newPage();
                }
            }
View Full Code Here

                // offsets the y co-ordinate by 15 units
                float y = -im.getScaledHeight() + 15;

                x = x + (signatureRect.getWidth() - im.getScaledWidth()) / 2;
                y = y - (signatureRect.getHeight() - im.getScaledHeight()) / 2;
                p.add(new Chunk(im, x + (signatureRect.getWidth() - im.getScaledWidth()) / 2, y, false));
                ct2.addElement(p);
                ct2.go();
            }
           
            if (size <= 0) {
View Full Code Here

            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 LwgFont(LwgFont.HELVETICA, 18, LwgFont.NORMAL, Color.yellow)).setBackground(Color.blue).setAction(action);
            ColumnText.showTextAligned(cb, LwgElement.ALIGN_CENTER, new LwgPhrase(ck), 250, 400, 0);
            cb.sanityCheck();
           
            // step 5: closing the document
            document.close();
View Full Code Here

          new FileOutputStream("Width.pdf"));

      // step 3: we open the document
      document.open();
      // step 4:
      Chunk c = new Chunk("quick brown fox jumps over the lazy dog");
      float w = c.getWidthPoint();
      Paragraph p = new Paragraph("The width of the chunk: '");
      p.add(c);
      p.add("' is ");
      p.add(String.valueOf(w));
      p.add(" points or ");
      p.add(String.valueOf(w / 72f));
      p.add(" inches.");
      document.add(p);
      document.add(c);
      document.add(Chunk.NEWLINE);
      c.setHorizontalScaling(0.5f);
      document.add(c);
      document.add(c);
    } catch (DocumentException de) {
      System.err.println(de.getMessage());
    } catch (IOException ioe) {
View Full Code Here

TOP

Related Classes of com.lowagie.text.Chunk

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.