Package com.itextpdf.text

Examples of com.itextpdf.text.Paragraph


          newPage();
        }
        // add dummy paragraph if we aren't at the top of a page, so that
        // spacingBefore will be taken into account by ColumnText
        if (currentHeight > 0) {
          Paragraph p = new Paragraph();
          p.setLeading(0);
          ct.addElement(p);
        }
        ct.addElement(ptable);
        boolean he = ptable.isHeadersInEvent();
        ptable.setHeadersInEvent(true);
        int loop = 0;
        while (true) {
            ct.setSimpleColumn(indentLeft(), indentBottom(), indentRight(), indentTop() - currentHeight);
            int status = ct.go();
            if ((status & ColumnText.NO_MORE_TEXT) != 0) {
                text.moveText(0, ct.getYLine() - indentTop() + currentHeight);
                currentHeight = indentTop() - ct.getYLine();
                break;
            }
            if (indentTop() - currentHeight == ct.getYLine())
                ++loop;
            else
                loop = 0;
            if (loop == 3) {
                add(new Paragraph("ERROR: Infinite table loop"));
                break;
            }
            newPage();
        }
        ptable.setHeadersInEvent(he);
View Full Code Here


   * Creates a Paragraph object based on a list of properties.
   * @param attributes
   * @return a Paragraph
   */
  public static Paragraph getParagraph(Properties attributes) {
    Paragraph paragraph = new Paragraph(getPhrase(attributes));
    String value;
    value = attributes.getProperty(ElementTags.ALIGN);
    if (value != null) {
      paragraph.setAlignment(value);
    }
    value = attributes.getProperty(ElementTags.INDENTATIONLEFT);
    if (value != null) {
      paragraph.setIndentationLeft(Float.parseFloat(value + "f"));
    }
    value = attributes.getProperty(ElementTags.INDENTATIONRIGHT);
    if (value != null) {
      paragraph.setIndentationRight(Float.parseFloat(value + "f"));
    }
    return paragraph;
  }
View Full Code Here

            c.setBackgroundColor(img.getBackgroundColor());
            t.addCell(c);
            element = t;
        }
        if (element.type() == Element.CHUNK) {
          element = new Paragraph((Chunk)element);
        }
        else if (element.type() == Element.PHRASE) {
          element = new Paragraph((Phrase)element);
        }
        if (element.type() != Element.PARAGRAPH && element.type() != Element.LIST && element.type() != Element.PTABLE && element.type() != Element.YMARK)
            throw new IllegalArgumentException(MessageLocalization.getComposedMessage("element.not.allowed"));
        if (!composite) {
            composite = true;
View Full Code Here

        while (true) {
            if (compositeElements.isEmpty())
                return NO_MORE_TEXT;
            Element element = compositeElements.getFirst();
            if (element.type() == Element.PARAGRAPH) {
                Paragraph para = (Paragraph)element;
                int status = 0;
                for (int keep = 0; keep < 2; ++keep) {
                    float lastY = yLine;
                    boolean createHere = false;
                    if (compositeColumn == null) {
                        compositeColumn = new ColumnText(canvas);
                        compositeColumn.setUseAscender(firstPass ? useAscender : false);
                        compositeColumn.setAlignment(para.getAlignment());
                        compositeColumn.setIndent(para.getIndentationLeft() + para.getFirstLineIndent());
                        compositeColumn.setExtraParagraphSpace(para.getExtraParagraphSpace());
                        compositeColumn.setFollowingIndent(para.getIndentationLeft());
                        compositeColumn.setRightIndent(para.getIndentationRight());
                        compositeColumn.setLeading(para.getLeading(), para.getMultipliedLeading());
                        compositeColumn.setRunDirection(runDirection);
                        compositeColumn.setArabicOptions(arabicOptions);
                        compositeColumn.setSpaceCharRatio(spaceCharRatio);
                        compositeColumn.addText(para);
                        if (!firstPass) {
                            yLine -= para.getSpacingBefore();
                        }
                        createHere = true;
                    }
                    compositeColumn.leftX = leftX;
                    compositeColumn.rightX = rightX;
                    compositeColumn.yLine = yLine;
                    compositeColumn.rectangularWidth = rectangularWidth;
                    compositeColumn.rectangularMode = rectangularMode;
                    compositeColumn.minY = minY;
                    compositeColumn.maxY = maxY;
                    boolean keepCandidate = para.getKeepTogether() && createHere && !firstPass;
                    status = compositeColumn.go(simulate || keepCandidate && keep == 0);
                    updateFilledWidth(compositeColumn.filledWidth);
                    if ((status & NO_MORE_TEXT) == 0 && keepCandidate) {
                        compositeColumn = null;
                        yLine = lastY;
                        return NO_MORE_COLUMN;
                    }
                    if (simulate || !keepCandidate)
                        break;
                    if (keep == 0) {
                        compositeColumn = null;
                        yLine = lastY;
                    }
                }
                firstPass = false;
                yLine = compositeColumn.yLine;
                linesWritten += compositeColumn.linesWritten;
                descender = compositeColumn.descender;
                if ((status & NO_MORE_TEXT) != 0) {
                    compositeColumn = null;
                    compositeElements.removeFirst();
                    yLine -= para.getSpacingAfter();
                }
                if ((status & NO_MORE_COLUMN) != 0) {
                    return NO_MORE_COLUMN;
                }
            }
View Full Code Here

                ct2.setSimpleColumn(signatureRect.getLeft(), signatureRect.getBottom(), signatureRect.getRight(), signatureRect.getTop(), 0, Element.ALIGN_RIGHT);

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

                Paragraph p = new Paragraph();
                // must calculate the point to draw from to make image appear in middle of column
                float x = 0;
                // experimentation found this magic number to counteract Adobe's signature graphic, which
                // 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

      }
    }
  }

  public static Paragraph createParagraph(ChainedProperties props) {
    Paragraph p = new Paragraph();
    createParagraph(p, props);
    return p;
  }
View Full Code Here

      }
      FactoryProperties.insertStyle(h, cprops);
      if (tag.equals(HtmlTags.ANCHOR)) {
        cprops.addToChain(tag, h);
        if (currentParagraph == null) {
          currentParagraph = new Paragraph();
        }
        stack.push(currentParagraph);
        currentParagraph = new Paragraph();
        return;
      }
      if (tag.equals(HtmlTags.NEWLINE)) {
        if (currentParagraph == null) {
          currentParagraph = new Paragraph();
        }
        currentParagraph.add(factoryProperties
            .createChunk("\n", cprops));
        return;
      }
      if (tag.equals(HtmlTags.HORIZONTALRULE)) {
        // Attempting to duplicate the behavior seen on Firefox with
        // http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_hr_test
        // where an initial break is only inserted when the preceding element doesn't
        // end with a break, but a trailing break is always inserted.
        boolean addLeadingBreak = true;
        if (currentParagraph == null) {
          currentParagraph = new Paragraph();
          addLeadingBreak = false;
        }
        if (addLeadingBreak) { // Not a new paragraph
          int numChunks = currentParagraph.getChunks().size();
          if (numChunks == 0 ||
View Full Code Here

        cprops.removeChain(tag);
        return;
      }
      if (tag.equals("a")) {
        if (currentParagraph == null) {
          currentParagraph = new Paragraph();
        }
        boolean skip = false;
        if (interfaceProps != null) {
          ALink i = (ALink) interfaceProps.get("alink_interface");
          if (i != null)
            skip = i.process(currentParagraph, cprops);
        }
        if (!skip) {
          String href = cprops.getProperty("href");
          if (href != null) {
            for (Chunk ck : currentParagraph.getChunks()) {
              ck.setAnchor(href);
            }
          }
        }
        Paragraph tmp = (Paragraph) stack.pop();
        Phrase tmp2 = new Phrase();
        tmp2.add(currentParagraph);
        tmp.add(tmp2);
        currentParagraph = tmp;
        cprops.removeChain("a");
        return;
      }
      if (tag.equals("br")) {
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

  /**
   * Erste Seite "Familienstammbaum der Familie XYZ".
   */
  private void addFirstPage(Person person) throws DocumentException {
    Paragraph paragraph = new Paragraph();
    paragraph.setAlignment(Element.ALIGN_CENTER);
    paragraph.add(new Chunk("\r\n\r\n\r\n\r\n\r\n\r\nFamilienstammbaum", fontHelvetica36Bold));
    document.add(paragraph);
    paragraph = new Paragraph();
    paragraph.setAlignment(Element.ALIGN_CENTER);
    paragraph.add(new Chunk("\r\n\r\n\r\n\r\nder Familie ", fontHelvetica24Bold));
    paragraph.setAlignment(Element.ALIGN_CENTER);
    paragraph.add(new Chunk("\r\n\r\n\r\n\r\n", fontHelvetica24BoldItalic));
    // paragraph.add(new Chunk(person.getValue(Person.NAME),
    // secondTitleFontItalic));
    Chunk chunk = new Chunk(person.getValue(Person.NAME), fontHelvetica24BoldItalic);
    Anchor anchor = new Anchor(chunk);
    anchor.setReference("#p-" + person.getXREFID());
    paragraph.add(anchor);
    document.add(paragraph);
  }
View Full Code Here

TOP

Related Classes of com.itextpdf.text.Paragraph

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.