Package com.lowagie.text

Examples of com.lowagie.text.Chunk


    }
   
    private Phrase composePhrase(String text, BaseFont ufont, Color color, float fontSize) {
        Phrase phrase = null;
        if (extensionFont == null && (substitutionFonts == null || substitutionFonts.isEmpty()))
            phrase = new Phrase(new Chunk(text, new Font(ufont, fontSize, 0, color)));
        else {
            FontSelector fs = new FontSelector();
            fs.addFont(new Font(ufont, fontSize, 0, color));
            if (extensionFont != null)
                fs.addFont(new Font(extensionFont, fontSize, 0, color));
View Full Code Here


                    app.setGrayFill(0);
                else
                    app.setColorFill(textColor);
                app.beginText();
                for (int k = 0; k < phrase.size(); ++k) {
                    Chunk ck = (Chunk)phrase.get(k);
                    BaseFont bf = ck.getFont().getBaseFont();
                    app.setFontAndSize(bf, usize);
                    StringBuffer sb = ck.append("");
                    for (int j = 0; j < sb.length(); ++j) {
                        String c = sb.substring(j, j + 1);
                        float wd = bf.getWidthPoint(c, usize);
                        app.setTextMatrix(extraMarginLeft + start - wd / 2, offsetY - extraMarginTop);
                        app.showText(c);
View Full Code Here

            style &= ~Font.UNDERLINE;
            style &= ~Font.STRIKETHRU;
            f.setStyle(Font.UNDEFINED);
            f.setStyle(style);
        }
        Chunk space = new Chunk(" ", f);
        space.process(this);
        carriageReturn();
        leading = oldleading;
    }
View Full Code Here

                       addLine(line); // add empty line - all cells need some lines even if they are empty
                       line = new PdfLine(currentLeft, currentRight, alignment, currentLineLeading);
                    }
                    else {
                        for (Iterator j = chunks.iterator(); j.hasNext();) {
                            Chunk c = (Chunk) j.next();
                            chunk = new PdfChunk(c, (PdfAction) (allActions.get(aCounter++)));
                            while ((overflow = line.add(chunk)) != null) {
                                addLine(line);
                                line = new PdfLine(currentLeft, currentRight, alignment, currentLineLeading);
                                chunk = overflow;
                            }
                        }
                    }
                    // if the element is a paragraph, section or chapter, we reset the alignment and add the line
                    switch (element.type()) {
                        case Element.PARAGRAPH:
                        case Element.SECTION:
                        case Element.CHAPTER:
                            line.resetAlignment();
                            flushCurrentLine();
                    }
            }
        }
        flushCurrentLine();
        if (lines.size() > cell.getMaxLines()) {
            while (lines.size() > cell.getMaxLines()) {
                removeLine(lines.size() - 1);
            }
            if (cell.getMaxLines() > 0) {
                String more = cell.getShowTruncation();
                if (more != null && more.length() > 0) {
                    // Denote that the content has been truncated
                    lastLine = (PdfLine) lines.get(lines.size() - 1);
                    if (lastLine.size() >= 0) {
                        PdfChunk lastChunk = lastLine.getChunk(lastLine.size() - 1);
                        float moreWidth = new PdfChunk(more, lastChunk).width();
                        while (lastChunk.toString().length() > 0 && lastChunk.width() + moreWidth > right - left) {
                            // Remove characters to leave room for the 'more' indicator
                            lastChunk.setValue(lastChunk.toString().substring(0, lastChunk.length() - 1));
                        }
                        lastChunk.setValue(lastChunk.toString() + more);
                    } else {
                        lastLine.add(new PdfChunk(new Chunk(more), null));
                    }
                }
            }
        }
        // we set some additional parameters
View Full Code Here

        if ((image.getAlignment() & Image.RIGHT) == Image.RIGHT) {
            left = right - image.getScaledWidth();
        } else if ((image.getAlignment() & Image.MIDDLE) == Image.MIDDLE) {
            left = left + ((right - left - image.getScaledWidth()) / 2f);
        }
        Chunk imageChunk = new Chunk(image, left, 0);
        imageLine.add(new PdfChunk(imageChunk, null));
        addLine(imageLine);
        return imageLine.height();
    }
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

  public Chunk createChunk(String text, ChainedProperties props) {
    Font 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

          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();
        Phrase tmp2 = new Phrase();
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

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.