Package com.lowagie.text

Examples of com.lowagie.text.Chunk


      final BaseFontFontMetrics fontMetrics = metaData.getBaseFontFontMetrics
          (fontName, fontSize, bold, italic, "utf-8", false, false);
      final BaseFont baseFont = fontMetrics.getBaseFont();
      final Font font = new Font(baseFont, (float) fontSize, style, textColor);
      final Chunk c = new Chunk(text, font);
      if (backgroundColor != null)
      {
        c.setBackground(backgroundColor);
      }
      target.add(c);
    }
View Full Code Here


        return new RtfBasicElement[]{rtfElement};
      }
      switch (element.type())
      {
        case Element.CHUNK:
          Chunk chunk = (Chunk) element;
          if (chunk.hasAttributes())
          {
            if (chunk.getAttributes().containsKey(Chunk.IMAGE))
            {
              rtfElements.add(new RtfImage(rtfDoc, chunk.getImage()));
            }
            else if (chunk.getAttributes().containsKey(Chunk.NEWPAGE))
            {
              rtfElements.add(new RtfNewPage(rtfDoc));
            }
            else if (chunk.getAttributes().containsKey(Chunk.TAB))
            {
              Float tabPos = (Float) ((Object[]) chunk.getAttributes().get(Chunk.TAB))[1];
              RtfTab tab = new RtfTab(tabPos.floatValue(), RtfTab.TAB_LEFT_ALIGN);
              tab.setRtfDocument(rtfDoc);
              rtfElements.add(tab);
              rtfElements.add(new RtfChunk(rtfDoc, new Chunk("\t")));
            }
            else
            {
              rtfElements.add(new RtfChunk(rtfDoc, (Chunk) element));
            }
View Full Code Here

      {
        RenderableReplacedContentBox content = (RenderableReplacedContentBox) c.getOriginatingTextNode();
        com.lowagie.text.Image image = imageHandler.createImage(content);
        if (image != null)
        {
          Chunk chunk = new Chunk(image, 0, 0);
        //  chunk.setFont(font);
          p.add(chunk);
        }
      }
      else
      {
        String textToPrint = c.getText();
        Chunk chunk = new Chunk(textToPrint, font);
        p.add(chunk);
      }
    }
    return p;
  }
View Full Code Here

    public static List createContents(java.util.List<DrlRuleParser> rules) {
        List index = new List( true );

        for ( DrlRuleParser drlRuleData : rules ) {
            Chunk chunk = new Chunk( drlRuleData.getName() );
            // chunk.setLocalGoto( item.getName() );
            ListItem listItem = new ListItem( chunk );
            index.add( listItem );
        }
View Full Code Here

  public Chunk createChunk(String text, ChainedProperties props) {
    LwgFont font = getFont(props);
    float size = font.getSize();
    size /= 2;
    Chunk ck = new Chunk(text, font);
    if (props.hasProperty("sub"))
      ck.setTextRise(-size);
    else if (props.hasProperty("sup"))
      ck.setTextRise(size);
    ck.setHyphenation(getHyphenation(props));
    return ck;
  }
View Full Code Here

     */
    public static Chunk get(String e, LwgFont font) {
        char s = getCorrespondingSymbol(e);
        if (s == (char)0) {
            try {
                return new Chunk(String.valueOf((char)Integer.parseInt(e)), font);
            }
            catch(Exception exception) {
                return new Chunk(e, font);
            }
        }
        LwgFont symbol = new LwgFont(LwgFont.SYMBOL, font.getSize(), font.getStyle(), font.getColor());
        return new Chunk(String.valueOf(s), symbol);
    }
View Full Code Here

          cprops.removeChain(tag);
          if (currentParagraph == null) {
            currentParagraph = FactoryProperties
                .createParagraph(cprops);
          }
          currentParagraph.add(new Chunk(img, 0, 0));
        }
        return;
      }
      endElement("p");
      if (tag.equals("h1") || tag.equals("h2") || tag.equals("h3")
View Full Code Here

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

    String content = str;
    if (isPRE) {
      if (currentParagraph == null) {
        currentParagraph = FactoryProperties.createParagraph(cprops);
      }
      Chunk chunk = factoryProperties.createChunk(content, cprops);
      currentParagraph.add(chunk);
      return;
    }
    if (content.trim().length() == 0 && content.indexOf(' ') < 0) {
      return;
    }

    StringBuffer buf = new StringBuffer();
    int len = content.length();
    char character;
    boolean newline = false;
    for (int i = 0; i < len; i++) {
      switch (character = content.charAt(i)) {
      case ' ':
        if (!newline) {
          buf.append(character);
        }
        break;
      case '\n':
        if (i > 0) {
          newline = true;
          buf.append(' ');
        }
        break;
      case '\r':
        break;
      case '\t':
        break;
      default:
        newline = false;
        buf.append(character);
      }
    }
    if (currentParagraph == null) {
      currentParagraph = FactoryProperties.createParagraph(cprops);
    }
    Chunk chunk = factoryProperties.createChunk(buf.toString(), cprops);
    currentParagraph.add(chunk);
  }
View Full Code Here

        }
            return;
          }
            case LwgElement.CHUNK:
            {
                Chunk chunk = (Chunk) element;
                // if the chunk contains an image, return the image representation
                LwgImage image = chunk.getImage();
                if (image != null) {
                    write(image, indent);
                    return;
                }
               
                if (chunk.isEmpty()) return;
                HashMap attributes = chunk.getAttributes();
                if (attributes != null && attributes.get(Chunk.NEWPAGE) != null) {
                    return;
                }
                boolean tag = isOtherFont(chunk.getFont()) || markup.size() > 0;
                if (tag) {
                    // start span tag
                    addTabs(indent);
                    writeStart(HtmlTags.SPAN);
                    if (isOtherFont(chunk.getFont())) {
                        write(chunk.getFont(), null);
                    }
                    writeMarkupAttributes(markup);
                    os.write(GT);
                }
                if (attributes != null && attributes.get(Chunk.SUBSUPSCRIPT) != null) {
                    // start sup or sub tag
                    if (((Float)attributes.get(Chunk.SUBSUPSCRIPT)).floatValue() > 0) {
                        writeStart(HtmlTags.SUP);
                    }
                    else {
                        writeStart(HtmlTags.SUB);
                    }
                    os.write(GT);
                }
                // contents
                write(HtmlEncoder.encode(chunk.getContent()));
                if (attributes != null && attributes.get(Chunk.SUBSUPSCRIPT) != null) {
                    // end sup or sub tag
                    os.write(LT);
                    os.write(FORWARD);
                    if (((Float)attributes.get(Chunk.SUBSUPSCRIPT)).floatValue() > 0) {
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.