Package com.itextpdf.text

Examples of com.itextpdf.text.Chunk


    String[] additionalTextList = new String[personList.length];
    sortPersonList(personList, relationType, additionalTextList, currPerson);
    if (personList.length > 0) {
      // Create pdf header of the person list.
      Paragraph paragraph = new Paragraph();
      paragraph.add(new Chunk("\r\n", fontHelvetica12));
      paragraph.add(new Chunk(personListHeader, fontHelvetica12));
      document.add(paragraph);

      // Person list.
      for (int i = 0; i < personList.length; i++) {
        Person person = personList[i];

        // Name extension.
        String nameExt = getNameExtension(currPerson, person);
        paragraph = new Paragraph();

        // Name of the person.
        String fullPersonName = person.getValue(Person.NAME) + nameExt;
        if (createPrintVersion) {
          fullPersonName += "  [" + (personsSorted.indexOf(person) + 1) + "]";
        }
        if (persons.contains(person)) {
          Chunk chunk = new Chunk(fullPersonName, fontTimes12ItalicBlue);
          Anchor iref = new Anchor(chunk);
          iref.setReference("#p-" + person.getXREFID());
          paragraph.add(iref);
        }
        else {
          Chunk chunk = new Chunk(fullPersonName, fontHelvetica12);
          paragraph.add(chunk);
        }

        // Extra text.
        if (additionalTextList[i] != null && additionalTextList[i].trim().length() > 0) {
          Chunk chunk = new Chunk("  " + additionalTextList[i].trim(), fontHelvetica12);
          paragraph.add(chunk);
        }

        paragraph.setIndentationLeft(8);
        document.add(paragraph);
View Full Code Here


  private void addAppendix_A_PersonsListedByBirthday() throws DocumentException {
    newPage();
    PersonListSort.sortByBirthday(persons);

    Paragraph paragraph = new Paragraph();
    Chunk chunk = new Chunk("Anhang A\r\n", fontHelvetica18Bold);
    Anchor anchor = new Anchor(chunk);
    anchor.setName("anhang-a");
    paragraph.add(anchor);
    document.add(paragraph);

    paragraph = new Paragraph();
    chunk = new Chunk("\r\n" + ANHANG_A_PERSONEN_SORTIERT_NACH_GEBURTSJAHR + "\r\n", fontHelvetica18BoldItalic);
    paragraph.add(chunk);
    document.add(paragraph);

    int lastYear = Integer.MIN_VALUE + 2;

    for (Person person : persons) {
      int currentBirthYear = person.getBirthYear(false);
      if (lastYear != currentBirthYear) {
        paragraph = new Paragraph();
        lastYear = currentBirthYear;
        String header = lastYear == Integer.MIN_VALUE ? "ohne Angabe" : Integer.toString(lastYear);
        chunk = new Chunk("\r\n" + header + "\r\n", fontHelvetica12Bold);
        anchor = new Anchor(chunk);
        anchor.setName("y-" + lastYear);
        paragraph.add(anchor);
        document.add(paragraph);
      }
      paragraph = new Paragraph();
      String fullname = person.getValue(Person.NAME);
      if (createPrintVersion) {
        fullname += "  [" + (personsSorted.indexOf(person) + 1) + "]";
      }
      chunk = new Chunk(fullname, fontTimes12ItalicBlue);
      anchor = new Anchor(chunk);
      anchor.setReference("#p-" + person.getXREFID());
      paragraph.add(anchor);
      document.add(paragraph);
    }
View Full Code Here

  private void addAppendix_B_PersonsListedByAge() throws DocumentException {
    newPage();
    PersonListSort.sortByAge(persons);

    Paragraph paragraph = new Paragraph();
    Chunk chunk = new Chunk("Anhang B\r\n", fontHelvetica18Bold);
    Anchor anchor = new Anchor(chunk);
    anchor.setName("anhang-b");
    paragraph.add(anchor);
    document.add(paragraph);

    paragraph = new Paragraph();
    chunk = new Chunk("\r\n" + ANHANG_B_VERSTORBENE_PERSONEN_SORTIERT_NACH_ALTER + "\r\n", fontHelvetica18BoldItalic);
    paragraph.add(chunk);
    document.add(paragraph);

    long lastAge = Integer.MIN_VALUE;

    for (Person person : persons) {
      String birthday = person.getValueView(Person.BIRTHDAY);
      long b = Statics.getYYYYMMDDlong(birthday);
      String deathday = person.getValueView(Person.DEATHDAY);
      long d = Statics.getYYYYMMDDlong(deathday);
      if (b >= 0 && d >= 0) {
        long currAge = (d - b) / 10000;
        if (currAge != lastAge) {
          paragraph = new Paragraph();
          lastAge = currAge;
          String header = "Alter: " + lastAge + " Jahre";
          chunk = new Chunk("\r\n" + header + "\r\n", fontHelvetica12Bold);
          paragraph.add(chunk);
          document.add(paragraph);
        }

        paragraph = new Paragraph();
        String fullname = person.getValue(Person.NAME);
        if (createPrintVersion) {
          fullname += "  [" + (personsSorted.indexOf(person) + 1) + "]";
        }
        chunk = new Chunk(fullname, fontTimes12ItalicBlue);
        anchor = new Anchor(chunk);
        anchor.setReference("#p-" + person.getXREFID());
        paragraph.add(anchor);
        paragraph.add(new Chunk("  (" + person.getShortDate() + ")"));
        document.add(paragraph);
      }
    }
  }
View Full Code Here

      if (content.trim().length() == 0 && content.indexOf(' ') < 0) {
        return;
      }
      content = HtmlUtilities.eliminateWhiteSpace(content);
    }
    Chunk chunk = createChunk(content);
    currentParagraph.add(chunk);
  }
View Full Code Here

        carriageReturn();
      }
      if (currentParagraph == null) {
        currentParagraph = createParagraph();
      }
      currentParagraph.add(new Chunk(img, 0, 0, true));
      currentParagraph.setAlignment(HtmlUtilities.alignmentValue(align));
      if (align != null) {
        carriageReturn();
      }
    }
View Full Code Here

   * @param chain the hierarchy chain
   * @return a Chunk
   */
  public Chunk createChunk(final String content, final ChainedProperties chain) {
    Font font = getFont(chain);
    Chunk ck = new Chunk(content, font);
    if (chain.hasProperty(HtmlTags.SUB))
      ck.setTextRise(-font.getSize() / 2);
    else if (chain.hasProperty(HtmlTags.SUP))
      ck.setTextRise(font.getSize() / 2);
    ck.setHyphenation(getHyphenation(chain));
    return ck;
  }
View Full Code Here

     */
    public static Chunk get(final String e, final 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

                // 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(signatureRect.getHeight());
                // must calculate the point to draw from to make image appear in middle of column
                x = (signatureRect.getWidth() - im.getScaledWidth()) / 2;
                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 List<Chunk> getChunks() {
      List<Chunk> list = new ArrayList<Chunk>();
      list.add(new Chunk(this, true));
        return list;
    }
View Full Code Here

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

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.