Examples of Paragraph


Examples of com.itextpdf.text.Paragraph

      document = new Document(PageSize.A4, 10, 10, 50, 50);
      PdfWriter instance = PdfWriter.getInstance(document, os);
      document.open();

      Paragraph paragraph = new Paragraph("Zestawienie czasu pracy pracownika za " + date
          + " - " + person, f);
      paragraph.setAlignment(Element.ALIGN_CENTER);
      document.add(paragraph);
      addEmptyLine(document, 2);
      PdfPTable table = new PdfPTable(5);

      Phrase phrase = new Phrase("Dzień miesiąca", f);
      PdfPCell c1 = new PdfPCell(phrase);
      c1.setHorizontalAlignment(Element.ALIGN_CENTER);
      table.addCell(c1);

      c1 = new PdfPCell(new Phrase("Czas pracy\u0144", f));
      c1.setHorizontalAlignment(Element.ALIGN_CENTER);
      table.addCell(c1);

      c1 = new PdfPCell(new Phrase("Program"));
      c1.setHorizontalAlignment(Element.ALIGN_CENTER);
      table.addCell(c1);

      c1 = new PdfPCell(new Phrase("Czas nieobecności", f));
      c1.setHorizontalAlignment(Element.ALIGN_CENTER);
      table.addCell(c1);

      c1 = new PdfPCell(new Phrase("Przyczyna nieobecność", f));
      c1.setHorizontalAlignment(Element.ALIGN_CENTER);
      table.addCell(c1);

      table.setHeaderRows(1);

      for (Day day : days) {
        PdfPCell cell = new PdfPCell(new Phrase(getValue(day.getDay()), f));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(getValue(day.getWorkTime()), f));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(getValue(day.getProgram()), f));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(getValue(day.getAbsenceTime()), f));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(getValue(day.getAbsenceReason()), f));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);

      }
      document.add(table);

      addEmptyLine(document, 3);
      Paragraph paragraph2 = new Paragraph("Podpis pracownika");
      paragraph2.setAlignment(Element.ALIGN_CENTER);
      document.add(paragraph2);
      Paragraph paragraph3 = new Paragraph("...........................................");
      paragraph3.setAlignment(Element.ALIGN_CENTER);
      document.add(paragraph3);
    } catch (Exception e) {
      throw new RuntimeException(e);
    } finally {
      if (document != null) {
View Full Code Here

Examples of com.itextpdf.text.Paragraph

    }
  }

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

Examples of com.lowagie.text.Paragraph

                    break;
                }
                case Element.PARAGRAPH: {
                  leadingCount++;
                    // we cast the element to a paragraph
                    Paragraph paragraph = (Paragraph) element;
                    addSpacing(paragraph.spacingBefore(), 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(Table.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.spacingAfter(), 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

Examples of com.lowagie.text.Paragraph

     * @throws DocumentException on error
     */
    void addPTable(PdfPTable ptable) throws DocumentException {
        ColumnText ct = new ColumnText(writer.getDirectContent());
        if (currentHeight > 0) {
            Paragraph p = new Paragraph();
            p.setLeading(0);
            ct.addElement(p);
            // if the table prefers to be on a single page, and it wouldn't
          //fit on the current page, start a new page.
          if (ptable.getKeepTogether() && !fitsPage(ptable, 0f))  {
            newPage();
          }
        }
        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

Examples of com.lowagie.text.Paragraph

                    float currentRight = right;
                    if (element instanceof Phrase) {
                        currentLineLeading = ((Phrase) element).getLeading();
                    }
                    if (element instanceof Paragraph) {
                        Paragraph p = (Paragraph) element;
                        currentLeft += p.getIndentationLeft();
                        currentRight -= p.getIndentationRight();
                    }
                    if (line == null) {
                        line = new PdfLine(currentLeft, currentRight, alignment, currentLineLeading);
                    }
                    // we loop over the chunks
View Full Code Here

Examples of com.lowagie.text.Paragraph

                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();
            }
           
            if (size <= 0) {
View Full Code Here

Examples of com.lowagie.text.Paragraph

      p.setLeading(0, 1.5f);
    }
  }

  public static Paragraph createParagraph(HashMap props) {
    Paragraph p = new Paragraph();
    String value = (String) props.get("align");
    if (value != null) {
      if (value.equalsIgnoreCase("center"))
        p.setAlignment(Element.ALIGN_CENTER);
      else if (value.equalsIgnoreCase("right"))
        p.setAlignment(Element.ALIGN_RIGHT);
      else if (value.equalsIgnoreCase("justify"))
        p.setAlignment(Element.ALIGN_JUSTIFIED);
    }
    p.setHyphenation(getHyphenation(props));
    setParagraphLeading(p, (String) props.get("leading"));
    return p;
  }
View Full Code Here

Examples of com.lowagie.text.Paragraph

      }
    }
  }

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

Examples of com.lowagie.text.Paragraph

      }
      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;
      }
View Full Code Here

Examples of com.lowagie.text.Paragraph

        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) {
            ArrayList chunks = currentParagraph.getChunks();
            int size = chunks.size();
            for (int k = 0; k < size; ++k) {
              Chunk ck = (Chunk) chunks.get(k);
              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
TOP
Copyright © 2018 www.massapi.com. 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.