Package com.itextpdf.text

Examples of com.itextpdf.text.Chunk


                    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


  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 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

     */
    public static Chunk get(String e, Font 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);
            }
        }
        Font symbol = new Font(FontFamily.SYMBOL, font.getSize(), font.getStyle(), font.getColor());
        return new Chunk(String.valueOf(s), symbol);
    }
View Full Code Here

     * @param value cell value
     * @return Cell
     */
    private PdfPCell getCell(String value)
    {
        PdfPCell cell = new PdfPCell(new Phrase(new Chunk(StringUtils.trimToEmpty(value), smallFont)));
        cell.setVerticalAlignment(Element.ALIGN_TOP);
        cell.setLeading(8, 0);
        cell.setPadding(2);
        return cell;
    }
View Full Code Here

     * @param model The table model containing the caption.
     * @throws DocumentException If an error occurrs while decorating the caption.
     */
    private void decorateCaption(TableModel model) throws DocumentException
    {
        Paragraph caption = new Paragraph(new Chunk(model.getCaption(), this.getCaptionFont()));
        caption.setAlignment(this.getCaptionHorizontalAlignment());
        this.document.add(caption);
    }
View Full Code Here

     * @throws DocumentException if an error occurs while writing post-body footer.
     */
    @Override
    protected void writePostBodyFooter(TableModel model) throws DocumentException
    {
        Chunk cellContent = new Chunk(model.getFooter(), this.getFooterFont());
        this.setFooterFontStyle(cellContent);
        PdfPCell cell = new PdfPCell(new Phrase(cellContent));
        cell.setLeading(8, 0);
        cell.setBackgroundColor(this.getFooterBackgroundColor());
        cell.setHorizontalAlignment(this.getFooterHorizontalAlignment());
View Full Code Here

     * @return Cell
     * @throws BadElementException if errors occurs while generating content.
     */
    private PdfPCell getCell(Object value)
    {
        PdfPCell cell = new PdfPCell(new Phrase(new Chunk(StringUtils.trimToEmpty(value != null
            ? value.toString()
            : StringUtils.EMPTY), this.defaultFont)));
        cell.setVerticalAlignment(Element.ALIGN_TOP);
        cell.setLeading(8, 0);
        return cell;
View Full Code Here

     * @param value Cell content.
     * @return A header cell with the given content.
     */
    private PdfPCell getHeaderCell(String value)
    {
        Chunk cellContent = new Chunk(value, this.getHeaderFont());
        setHeaderFontStyle(cellContent);
        PdfPCell cell = new PdfPCell(new Phrase(cellContent));
        cell.setLeading(8, 0);
        cell.setHorizontalAlignment(this.getHeaderHorizontalAlignment());
        cell.setBackgroundColor(this.getHeaderBackgroundColor());
View Full Code Here

TOP

Related Classes of com.itextpdf.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.