Package com.itextpdf.text

Examples of com.itextpdf.text.Chunk


     * @return Returns the Chunk.
     */
    public Chunk create(final String text, final String in1, final String in2,
            final String in3) {

        Chunk chunk = new Chunk(text);
        String tag = "idx_" + indexcounter++;
        chunk.setGenericTag(tag);
        chunk.setLocalDestination(tag);
        Entry entry = new Entry(in1, in2, in3, tag);
        indexentry.add(entry);
        return chunk;
    }
View Full Code Here


     */
    public PdfOutline(PdfOutline parent, PdfDestination destination, Paragraph title, boolean open) {
        super();
        StringBuffer buf = new StringBuffer();
        for (Object element : title.getChunks()) {
            Chunk chunk = (Chunk) element;
            buf.append(chunk.getContent());
        }
        this.destination = destination;
        initOutline(parent, buf.toString(), open);
    }
View Full Code Here

                for (int f = 0; f < fsize; ++f) {
                    font = fonts.get(f);
                    if (font.getBaseFont().charExists(u)) {
                        if (lastidx != f) {
                            if (sb.length() > 0 && lastidx != -1) {
                                Chunk ck = new Chunk(sb.toString(), fonts.get(lastidx));
                                ret.add(ck);
                                sb.setLength(0);
                            }
                            lastidx = f;
                        }
                        sb.append(c);
                        sb.append(cc[++k]);
                        break;
                    }
                }
            }
            else {
                for (int f = 0; f < fsize; ++f) {
                    font = fonts.get(f);
                    if (font.getBaseFont().charExists(c)) {
                        if (lastidx != f) {
                            if (sb.length() > 0 && lastidx != -1) {
                                Chunk ck = new Chunk(sb.toString(), fonts.get(lastidx));
                                ret.add(ck);
                                sb.setLength(0);
                            }
                            lastidx = f;
                        }
                        sb.append(c);
                        break;
                    }
                }
            }
        }
        if (sb.length() > 0) {
            Chunk ck = new Chunk(sb.toString(), fonts.get(lastidx == -1 ? 0 : lastidx));
            ret.add(ck);
        }
        return ret;
    }
View Full Code Here

            this.image = image;
            column.setLeading(0, 1);
            setPadding(borderWidth / 2);
        }
        else {
            column.addText(this.phrase = new Phrase(new Chunk(image, 0, 0)));
            column.setLeading(0, 1);
            setPadding(0);
        }
    }
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

   * 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

                // 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();
                break;
            case GRAPHIC:
                ct2 = new ColumnText(t);
                ct2.setRunDirection(runDirection);
                ct2.setSimpleColumn(signatureRect.getLeft(), signatureRect.getBottom(), signatureRect.getRight(), signatureRect.getTop(), 0, Element.ALIGN_RIGHT);

                im = Image.getInstance(signatureGraphic);
                im.scaleToFit(signatureRect.getWidth(), signatureRect.getHeight());

                p = new Paragraph();
                // must calculate the point to draw from to make image appear in middle of column
                x = 0;
                // experimentation found this magic number to counteract Adobe's signature graphic, which
                // offsets the y co-ordinate by 15 units
                y = -im.getScaledHeight() + 15;

                x = x + (signatureRect.getWidth() - im.getScaledWidth()) / 2;
                y = y - (signatureRect.getHeight() - im.getScaledHeight()) / 2;
                p.add(new Chunk(im, x, y, false));
                ct2.addElement(p);
                ct2.go();
                break;
            default:
            }
View Full Code Here

    /**
     * @see com.itextpdf.text.Element#getChunks()
     */
    public ArrayList<Chunk> getChunks() {
      ArrayList<Chunk> list = new ArrayList<Chunk>();
      list.add(new Chunk(this, true));
        return list;
    }
View Full Code Here

    }

    private Phrase composePhrase(String text, BaseFont ufont, BaseColor 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

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.