Package com.itextpdf.text

Examples of com.itextpdf.text.Paragraph


   * a new span.
   * @since 5.0.6
   */
  public void flushContent() {
    pushToStack(currentParagraph);
    currentParagraph = new Paragraph();
  }
View Full Code Here


   * Adds a link to the current paragraph.
   * @since 5.0.6
   */
  public void processLink() {
    if (currentParagraph == null) {
      currentParagraph = new Paragraph();
    }
    // The link provider allows you to do additional processing
    LinkProcessor i = (LinkProcessor) providers.get(HTMLWorker.LINK_PROVIDER);
    if (i == null || !i.process(currentParagraph, chain)) {
      // sets an Anchor for all the Chunks in the current paragraph
      String href = chain.getProperty(HtmlTags.HREF);
      if (href != null) {
        for (Chunk ck : currentParagraph.getChunks()) {
          ck.setAnchor(href);
        }
      }
    }
    // a link should be added to the current paragraph as a phrase
    if (stack.isEmpty()) {
      // no paragraph to add too, 'a' tag is first element
      Paragraph tmp = new Paragraph(new Phrase(currentParagraph));
      currentParagraph = tmp;
    } else {
      Paragraph tmp = (Paragraph) stack.pop();
      tmp.add(new Phrase(currentParagraph));
      currentParagraph = tmp;
    }
  }
View Full Code Here

                    break;
                }
                case Element.PARAGRAPH: {
                  leadingCount++;
                    // we cast the element to a paragraph
                    Paragraph paragraph = (Paragraph) element;
                    addSpacing(paragraph.getSpacingBefore(), leading, paragraph.getFont());

                    // we adjust the parameters of the document
                    alignment = paragraph.getAlignment();
                    leading = paragraph.getTotalLeading();
                    carriageReturn();

                    // we don't want to make orphans/widows
                    if (currentHeight + line.height() + leading > indentTop() - indentBottom()) {
                        newPage();
                    }
                    indentation.indentLeft += paragraph.getIndentationLeft();
                    indentation.indentRight += paragraph.getIndentationRight();
                    carriageReturn();

                    PdfPageEvent pageEvent = writer.getPageEvent();
                    if (pageEvent != null && !isSectionTitle)
                        pageEvent.onParagraph(writer, this, indentTop() - currentHeight);

                    // if a paragraph has to be kept together, we wrap it in a table object
                    if (paragraph.getKeepTogether()) {
                      carriageReturn();
                        PdfPTable table = new PdfPTable(1);
                        table.setWidthPercentage(100f);
                        PdfPCell cell = new PdfPCell();
                        cell.addElement(paragraph);
                        cell.setBorder(Rectangle.NO_BORDER);
                        cell.setPadding(0);
                        table.addCell(cell);
                        indentation.indentLeft -= paragraph.getIndentationLeft();
                        indentation.indentRight -= paragraph.getIndentationRight();
                        this.add(table);
                        indentation.indentLeft += paragraph.getIndentationLeft();
                        indentation.indentRight += paragraph.getIndentationRight();
                    }
                    else {
                      line.setExtraIndent(paragraph.getFirstLineIndent());
                      element.process(this);
                        carriageReturn();
                        addSpacing(paragraph.getSpacingAfter(), paragraph.getTotalLeading(), paragraph.getFont());
                    }

                    if (pageEvent != null && !isSectionTitle)
                        pageEvent.onParagraphEnd(writer, this, indentTop() - currentHeight);

                    alignment = Element.ALIGN_LEFT;
                    indentation.indentLeft -= paragraph.getIndentationLeft();
                    indentation.indentRight -= paragraph.getIndentationRight();
                    carriageReturn();
                    leadingCount--;
                    break;
                }
                case Element.SECTION:
View Full Code Here

    return table;
  }

  private static void addEmptyLine(Paragraph paragraph, int number) {
    for (int i = 0; i < number; i++) {
      paragraph.add(new Paragraph(" "));
    }
  }
View Full Code Here

      e.printStackTrace();
    }
  }

  private void addContent(Document document) throws DocumentException {
    Paragraph twoEmptyLine = new Paragraph();
    addEmptyLine(twoEmptyLine, 2);
    Paragraph oneEmptyLine = new Paragraph();
    addEmptyLine(oneEmptyLine, 1);

    /**
     * Add the logo
     */
    try {
      Image image = Image.getInstance(pathFile.get("util")
          + (osName.toLowerCase().startsWith("linux") ? "/logo.png" : "\\logo.png"));
      image.setAlignment(Element.ALIGN_LEFT);
      image.setWidthPercentage(50);
      document.add(image);
    } catch (MalformedURLException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }

    /**
     * Add the event name
     */
    Paragraph eventNameParagraph = new Paragraph(event.getName() + " " + requiredGender.toUpperCase(), headerFont2);
    document.add(eventNameParagraph);
    document.add(oneEmptyLine);

    // table
    PdfPTable table = getResultsTable();
View Full Code Here

    cell.disableBorderSide(PdfPCell.BOTTOM);
  }

  private static void addEmptyLine(Paragraph paragraph, int number) {
    for (int i = 0; i < number; i++) {
      paragraph.add(new Paragraph(" "));
    }
  }
View Full Code Here

    }
  }

  private void addContent(Document document) throws DocumentException {

    Paragraph twoEmptyLine = new Paragraph();
    addEmptyLine(twoEmptyLine, 2);
    Paragraph oneEmptyLine = new Paragraph();
    addEmptyLine(oneEmptyLine, 1);

    /**
     * Add the Title paragraph
     */
    Paragraph titleParagraph = new Paragraph(competitionTitle, titleFont);
    titleParagraph.setAlignment(Element.ALIGN_CENTER);
    document.add(titleParagraph);
    document.add(twoEmptyLine);

    /**
     * Add the date
     */
    Format format = new SimpleDateFormat("EEEE dd MMM yyyy");
    Paragraph dateParagraph = new Paragraph(format.format((new Date())), headerFont2);
    document.add(dateParagraph);
    document.add(twoEmptyLine);

    /**
     * Add the event name
     */
    Paragraph eventNameParagraph = new Paragraph(event.getName().toUpperCase(), headerFont1);
    eventNameParagraph.setAlignment(Element.ALIGN_CENTER);
    document.add(eventNameParagraph);
    document.add(oneEmptyLine);

    /**
     * Add the heat number
     */
    Paragraph heatNumberParagraph = new Paragraph("Seria " + heat.getHeatNumber(), headerFont2);
    heatNumberParagraph.setAlignment(Element.ALIGN_CENTER);
    document.add(heatNumberParagraph);
    document.add(oneEmptyLine);

    /**
     * Table of heats
View Full Code Here

    }
  }

  private void addContent(Document document) throws DocumentException {

    Paragraph twoEmptyLine = new Paragraph();
    addEmptyLine(twoEmptyLine, 2);
    Paragraph oneEmptyLine = new Paragraph();
    addEmptyLine(oneEmptyLine, 1);
    /**
     * Add the logo
     */
    try {
      Image image = Image.getInstance(pathFile.get("util")
          + (osName.toLowerCase().startsWith("linux") ? "/logo.png" : "\\logo.png"));
      image.setAlignment(Element.ALIGN_LEFT);
      document.add(image);
    } catch (MalformedURLException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }

    /**
     * Add the event name
     */
    Paragraph eventNameParagraph = new Paragraph(event.getName(), headerFont2);
    document.add(eventNameParagraph);
    document.add(oneEmptyLine);

    // table
    PdfPTable table = getHeatTable();
View Full Code Here

    cell.disableBorderSide(PdfPCell.BOTTOM);
  }

  private static void addEmptyLine(Paragraph paragraph, int number) {
    for (int i = 0; i < number; i++) {
      paragraph.add(new Paragraph(" "));
    }
  }
View Full Code Here

                    break;
                }
                case Element.PARAGRAPH: {
                  leadingCount++;
                    // we cast the element to a paragraph
                    Paragraph paragraph = (Paragraph) element;
                    addSpacing(paragraph.getSpacingBefore(), leading, paragraph.getFont());

                    // we adjust the parameters of the document
                    alignment = paragraph.getAlignment();
                    leading = paragraph.getTotalLeading();
                    carriageReturn();

                    // we don't want to make orphans/widows
                    if (currentHeight + line.height() + leading > indentTop() - indentBottom()) {
                        newPage();
                    }
                    indentation.indentLeft += paragraph.getIndentationLeft();
                    indentation.indentRight += paragraph.getIndentationRight();
                    carriageReturn();

                    PdfPageEvent pageEvent = writer.getPageEvent();
                    if (pageEvent != null && !isSectionTitle)
                        pageEvent.onParagraph(writer, this, indentTop() - currentHeight);

                    // if a paragraph has to be kept together, we wrap it in a table object
                    if (paragraph.getKeepTogether()) {
                      carriageReturn();
                        PdfPTable table = new PdfPTable(1);
                        table.setWidthPercentage(100f);
                        PdfPCell cell = new PdfPCell();
                        cell.addElement(paragraph);
                        cell.setBorder(Rectangle.NO_BORDER);
                        cell.setPadding(0);
                        table.addCell(cell);
                        indentation.indentLeft -= paragraph.getIndentationLeft();
                        indentation.indentRight -= paragraph.getIndentationRight();
                        this.add(table);
                        indentation.indentLeft += paragraph.getIndentationLeft();
                        indentation.indentRight += paragraph.getIndentationRight();
                    }
                    else {
                      line.setExtraIndent(paragraph.getFirstLineIndent());
                      element.process(this);
                        carriageReturn();
                        addSpacing(paragraph.getSpacingAfter(), paragraph.getTotalLeading(), paragraph.getFont());
                    }

                    if (pageEvent != null && !isSectionTitle)
                        pageEvent.onParagraphEnd(writer, this, indentTop() - currentHeight);

                    alignment = Element.ALIGN_LEFT;
                    indentation.indentLeft -= paragraph.getIndentationLeft();
                    indentation.indentRight -= paragraph.getIndentationRight();
                    carriageReturn();
                    leadingCount--;
                    break;
                }
                case Element.SECTION:
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.