Package com.itextpdf.text

Examples of com.itextpdf.text.Paragraph


   * Adds a new line to the currentParagraph.
   * @since 5.0.6
   */
  public void newLine() {
    if (currentParagraph == null) {
      currentParagraph = new Paragraph();
    }
    currentParagraph.add(createChunk("\n"));
  }
View Full Code Here


   * 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

   * of the different tags and properties in the hierarchy chain.
   * @param  chain  the hierarchy chain
   * @return  a Paragraph without any content
   */
  public Paragraph createParagraph(final ChainedProperties chain) {
    Paragraph paragraph = new Paragraph();
    updateElement(paragraph, chain);
    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.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 && adjustFirstLine)) {
                            yLine -= para.getSpacingBefore();
                        }
                        createHere = true;
                    }
                    compositeColumn.setUseAscender(firstPass && adjustFirstLine ? useAscender : false);
                    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 && adjustFirstLine);
                    status = compositeColumn.go(simulate || keepCandidate && keep == 0);
                    lastX = compositeColumn.getLastX();
                    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

                    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

    }

    private static void addPage(Document document)
        throws DocumentException, MalformedURLException, IOException {

      Paragraph header2 = new Paragraph();
      header2.setAlignment(Element.ALIGN_LEFT);
     
      header2.add(new Paragraph("Computerservice � Matthias M�ller � Rheingoldstr. 38a � 56329 St. Goar", headerAdressFont));
     
      header2.add(new LineSeparator((float) 0.8, 100, BaseColor.BLACK, Element.ALIGN_CENTER, 12));
     
      Paragraph adresse = new Paragraph();
      //adresse.add(new Paragraph(" ", new Font(Font.FontFamily.TIMES_ROMAN, 8)));
      float[] relSize = {3, 2};
      PdfPTable table = new PdfPTable(relSize);
      table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
      table.setWidthPercentage(100);
     
      Font adressFont = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL);
     
      table.addCell("");
      table.addCell("");
      table.addCell("");
      table.addCell(new Phrase("Matthias M�ller Computerservice", new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD)));
      table.addCell("");
      table.addCell(new Phrase("Rheingoldstr. 38a", adressFont));
      table.addCell(anrede);
      table.addCell(new Phrase("56329 St. Goar", adressFont));
      table.addCell(vorname+" "+nachname);
      table.addCell("");
      table.addCell(strasse);
      table.addCell(new Phrase("Telefon:  0 67 41 / 20 74 06", adressFont));
      table.addCell(plz+" "+ort);
      table.addCell(new Phrase("Mobil:     01 52 / 09 80 91 92", adressFont));
      table.addCell("");
       
        //Mail
        Phrase adressPh = new Phrase();
 
        adressPh.add(new Chunk("E-Mail:   ", adressFont));
          Anchor emailLink = new Anchor("kontakt@muellerpc.de", new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.UNDERLINE, new BaseColor(Color.BLUE)));
          emailLink.setReference("mailto:kontakt@muellerpc.de");
        adressPh.add(emailLink);
     
      table.addCell(adressPh);
      table.addCell("");
      table.addCell("");
      table.addCell("");
      table.addCell(new Phrase("Datum:   "+adressDate.format(date)+"", adressFont));
     
      adresse.add(table);
     
      Paragraph main = new Paragraph();
     
      main.add(new Paragraph(" "));
      main.add(new Paragraph("Gehaltsabrechnung "+monat.format(date), new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD)));
     
      //anfang main
     
      float[] relSizeMain = {1,1,1,1,1};
      PdfPTable tableMain = new PdfPTable(relSizeMain);
      tableMain.getDefaultCell().setBorder(Rectangle.BOX);
     
      PdfPCell cH1 = new PdfPCell(new Phrase("Krankenkasse", mainBigFont));
      cH1.setHorizontalAlignment(Element.ALIGN_CENTER);
      tableMain.addCell(cH1);
     
      PdfPCell cH2 = new PdfPCell(new Phrase("Bundesland", mainBigFont));
      cH2.setHorizontalAlignment(Element.ALIGN_CENTER);
      tableMain.addCell(cH2);
     
      PdfPCell cH3 = new PdfPCell(new Phrase("Religion", mainBigFont));
      cH3.setHorizontalAlignment(Element.ALIGN_CENTER);
      tableMain.addCell(cH3);

      PdfPCell cH4 = new PdfPCell(new Phrase("Geb. Datum", mainBigFont));
      cH4.setHorizontalAlignment(Element.ALIGN_CENTER);
      tableMain.addCell(cH4);
     
      PdfPCell cH5 = new PdfPCell(new Phrase("Kinder", mainBigFont));
      cH5.setHorizontalAlignment(Element.ALIGN_CENTER);
      tableMain.addCell(cH5);
     
      tableMain.setHeaderRows(1);
     
      tableMain.addCell(krankenkasse);
      tableMain.addCell(bundesland);
      tableMain.addCell(religion);
      tableMain.addCell(abrechnDate.format(gebDate));
      tableMain.addCell(""+kinder);
     
      float[] relSizeMainGehalt = {12,3,8,8};
      PdfPTable tableMainGehalt = new PdfPTable(relSizeMainGehalt);
      tableMainGehalt.getDefaultCell().setBorder(Rectangle.BOX);
     
      PdfPCell cA1 = new PdfPCell(new Phrase("Ab-/Bez�ge", mainBigFont));
      cA1.setHorizontalAlignment(Element.ALIGN_CENTER);
      tableMainGehalt.addCell(cA1);
     
      PdfPCell cA2 = new PdfPCell(new Phrase("%", mainBigFont));
      cA2.setHorizontalAlignment(Element.ALIGN_CENTER);
      tableMainGehalt.addCell(cA2);
     
      PdfPCell cA3 = new PdfPCell(new Phrase("Teilbetr�ge", mainBigFont));
      cA3.setHorizontalAlignment(Element.ALIGN_CENTER);
      tableMainGehalt.addCell(cA3);
     
      PdfPCell cA4 = new PdfPCell(new Phrase("Gesamtbetrag", mainBigFont));
      cA4.setHorizontalAlignment(Element.ALIGN_CENTER);
      tableMainGehalt.addCell(cA4);
     
      tableMainGehalt.setHeaderRows(1);
     
      tableMainGehalt.addCell("Bruttogehalt");
      tableMainGehalt.addCell("");
      PdfPCell c = new PdfPCell(new Phrase(df.format(bruttogehalt)));
      c.setHorizontalAlignment(Element.ALIGN_RIGHT);
      tableMainGehalt.addCell(c);
      tableMainGehalt.addCell("");
   
      tableMainGehalt.addCell("+ Sonstige Bez�ge");
      tableMainGehalt.addCell("");
      c = new PdfPCell(new Phrase(df.format(sonstBezug)));
      c.setHorizontalAlignment(Element.ALIGN_RIGHT);
      tableMainGehalt.addCell(c);
      tableMainGehalt.addCell("");
     
      tableMainGehalt.addCell("- Sonstige Abz�ge");
      tableMainGehalt.addCell("");
      c = new PdfPCell(new Phrase(df.format(sonstAbzug)));
      c.setHorizontalAlignment(Element.ALIGN_RIGHT);
      tableMainGehalt.addCell(c);
      tableMainGehalt.addCell("");
     
     
      PdfPCell c6 = new PdfPCell(new Phrase("= Zu versteuerndes Einkommen"));
      c6.setBorderWidthBottom(1);
      tableMainGehalt.addCell(c6);
     
      PdfPCell c7 = new PdfPCell(new Phrase(""));
      c7.setBorderWidthRight(0);
      c7.setBorderWidthLeft(0);
      c7.setBorderWidthBottom(1);
      tableMainGehalt.addCell(c7);
     
      PdfPCell c8 = new PdfPCell(new Phrase(""));
      c8.setBorderWidthRight(0);
      c8.setBorderWidthBottom(1);
      tableMainGehalt.addCell(c8);
     
      PdfPCell c9 = new PdfPCell(new Phrase(df.format(zuVersteuerndesEinkommen)));
      c9.setBorderWidthBottom(1);
      c9.setHorizontalAlignment(Element.ALIGN_RIGHT);
      tableMainGehalt.addCell(c9);
     
      tableMainGehalt.addCell("- Lohnsteuer");
      tableMainGehalt.addCell("");
      c = new PdfPCell(new Phrase(df.format(lohnsteuer)));
      c.setHorizontalAlignment(Element.ALIGN_RIGHT);
      tableMainGehalt.addCell(c);
      tableMainGehalt.addCell("");
     
      tableMainGehalt.addCell("- Kirchensteuer");
      c = new PdfPCell(new Phrase(pf.format(prozentKirchensteuer)+" %"));
      c.setHorizontalAlignment(Element.ALIGN_RIGHT);
      tableMainGehalt.addCell(c);
      c = new PdfPCell(new Phrase(df.format(kirchensteuer)));
      c.setHorizontalAlignment(Element.ALIGN_RIGHT);
      tableMainGehalt.addCell(c);
      tableMainGehalt.addCell("");
     
      tableMainGehalt.addCell("- Solidarit�tszuschlag");
      tableMainGehalt.addCell("");
      c = new PdfPCell(new Phrase(df.format(soli)));
      c.setHorizontalAlignment(Element.ALIGN_RIGHT);
      tableMainGehalt.addCell(c);
      tableMainGehalt.addCell("");
           
      PdfPCell c10 = new PdfPCell(new Phrase("= Zu Gesamte Steuerabz�ge"));
      c10.setBorderWidthBottom(1);
      tableMainGehalt.addCell(c10);
     
      PdfPCell c11 = new PdfPCell(new Phrase(""));
      c11.setBorderWidthRight(0);
      c11.setBorderWidthLeft(0);
      c11.setBorderWidthBottom(1);
      tableMainGehalt.addCell(c11);
     
      PdfPCell c12 = new PdfPCell(new Phrase(""));
      c12.setBorderWidthRight(0);
      c12.setBorderWidthBottom(1);
      tableMainGehalt.addCell(c12);
     
      PdfPCell c13 = new PdfPCell(new Phrase(df.format(gesSteuerabzug)));
      c13.setBorderWidthBottom(1);
      c13.setHorizontalAlignment(Element.ALIGN_RIGHT);
      tableMainGehalt.addCell(c13);
     
     
      tableMainGehalt.addCell("- Krankenversicherung");
      c = new PdfPCell(new Phrase(pf.format(prozentKrankenversicherung)+" %"));
      c.setHorizontalAlignment(Element.ALIGN_RIGHT);
      tableMainGehalt.addCell(c);
      c = new PdfPCell(new Phrase(df.format(krankenversicherung)));
      c.setHorizontalAlignment(Element.ALIGN_RIGHT);
      tableMainGehalt.addCell(c);
      tableMainGehalt.addCell("");
     
      tableMainGehalt.addCell("- Pflegeversicherung");
      c = new PdfPCell(new Phrase(pf.format(prozentPflegeversicherung)+" %"));
      c.setHorizontalAlignment(Element.ALIGN_RIGHT);
      tableMainGehalt.addCell(c);
      c = new PdfPCell(new Phrase(df.format(pflegeversicherung)));
      c.setHorizontalAlignment(Element.ALIGN_RIGHT);
      tableMainGehalt.addCell(c);
      tableMainGehalt.addCell("");
     
      tableMainGehalt.addCell("- Rentenversicherung");
      c = new PdfPCell(new Phrase(pf.format(prozentRentenversicherung)+" %"));
      c.setHorizontalAlignment(Element.ALIGN_RIGHT);
      tableMainGehalt.addCell(c);
      c = new PdfPCell(new Phrase(df.format(rentenversicherung)));
      c.setHorizontalAlignment(Element.ALIGN_RIGHT);
      tableMainGehalt.addCell(c);
      tableMainGehalt.addCell("");
     
      tableMainGehalt.addCell("- Arbeitslosenversicherung");
      c = new PdfPCell(new Phrase(pf.format(prozentArbeitslosenversicherung)+" %"));
      c.setHorizontalAlignment(Element.ALIGN_RIGHT);
      tableMainGehalt.addCell(c);
      c = new PdfPCell(new Phrase(df.format(arbeitslosenversicherung)));
      c.setHorizontalAlignment(Element.ALIGN_RIGHT);
      tableMainGehalt.addCell(c);
      tableMainGehalt.addCell("");
           
      PdfPCell c14 = new PdfPCell(new Phrase("= Gesamte Sozialver. Abz�ge"));
      c14.setBorderWidthTop(0);
      c14.setBorderWidthBottom(1);
      tableMainGehalt.addCell(c14);
     
      PdfPCell c15 = new PdfPCell(new Phrase(""));
      c15.setBorderWidthTop(0);
      c15.setBorderWidthRight(0);
      c15.setBorderWidthLeft(0);
      c15.setBorderWidthBottom(1);
      tableMainGehalt.addCell(c15);
     
      PdfPCell c16 = new PdfPCell(new Phrase(""));
      c16.setBorderWidthTop(0);
      c16.setBorderWidthRight(0);
      c16.setBorderWidthBottom(1);
      tableMainGehalt.addCell(c16);
     
      PdfPCell c17 = new PdfPCell(new Phrase(df.format(gesSozialversicherungsabzug)));
      c17.setBorderWidthTop(0);
      c17.setBorderWidthBottom(1);
      c17.setHorizontalAlignment(Element.ALIGN_RIGHT);
      tableMainGehalt.addCell(c17);
     
      tableMainGehalt.addCell("= Nettogehalt");
      tableMainGehalt.addCell("");
      tableMainGehalt.addCell("");
      c = new PdfPCell(new Phrase(df.format(nettogehalt)));
      c.setHorizontalAlignment(Element.ALIGN_RIGHT);
      tableMainGehalt.addCell(c);
     
     
      PdfPCell c18 = new PdfPCell(new Phrase(""));
      c18.setColspan(4);
      c18.setBorderWidth(1);
      c18.setBorderWidthLeft(0);
      c18.setBorderWidthRight(0);
      tableMainGehalt.addCell(c18);
     
     
      PdfPCell c19 = new PdfPCell(new Phrase(""));
      c19.setColspan(4);
      c19.setBorderWidth(0);
      tableMainGehalt.addCell(c19);
     
      float[] relSizeBorder = {1};
      PdfPTable tableBorder = new PdfPTable(relSizeBorder);
      tableBorder.getDefaultCell().setBorderWidth(1);
      tableBorder.setWidthPercentage(100);
      tableBorder.addCell(tableMain);
      tableBorder.addCell(tableMainGehalt);
     
      main.add(tableBorder);
      //ende main
      PdfPTable header1 = new PdfPTable(1);
      PdfPCell cell = new PdfPCell(new Phrase(" ", FontFactory.getFont(FontFactory.HELVETICA, 54)));
      cell.setBorder(Rectangle.NO_BORDER);
      cell.setBorderWidth(0);
View Full Code Here

   * Adds a new line to the currentParagraph.
   * @since 5.0.6
   */
  public void newLine() {
    if (currentParagraph == null) {
      currentParagraph = new Paragraph();
    }
    currentParagraph.add(createChunk("\n"));
  }
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.