Package com.itextpdf.text

Examples of com.itextpdf.text.Phrase


     * @param chunk the text
     */
    public void addText(Chunk chunk) {
        if (chunk == null || composite)
            return;
        addText(new Phrase(chunk));
    }
View Full Code Here


                yLine = compositeColumn.yLine;
                linesWritten += compositeColumn.linesWritten;
                descender = compositeColumn.descender;
                if (!Float.isNaN(compositeColumn.firstLineY) && !compositeColumn.firstLineYDone) {
                    if (!simulate)
                        showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(item.getListSymbol()), compositeColumn.leftX + listIndentation, compositeColumn.firstLineY, 0);
                    compositeColumn.firstLineYDone = true;
                }
                if ((status & NO_MORE_TEXT) != 0) {
                    compositeColumn = null;
                    ++listIdx;
View Full Code Here

                Rectangle sr2 = new Rectangle(signatureRect.getWidth() - MARGIN, signatureRect.getHeight() - MARGIN );
                float signedSize = fitText(font, signedBy, sr2, -1, runDirection);

                ColumnText ct2 = new ColumnText(t);
                ct2.setRunDirection(runDirection);
                ct2.setSimpleColumn(new Phrase(signedBy, font), signatureRect.getLeft(), signatureRect.getBottom(), signatureRect.getRight(), signatureRect.getTop(), signedSize, Element.ALIGN_LEFT);

                ct2.go();
                break;
            case GRAPHIC_AND_DESCRIPTION:
                ct2 = new ColumnText(t);
                ct2.setRunDirection(runDirection);
                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:
            }

            if(renderingMode != RenderingMode.GRAPHIC) {
              if (size <= 0) {
                    Rectangle sr = new Rectangle(dataRect.getWidth(), dataRect.getHeight());
                    size = fitText(font, text, sr, 12, runDirection);
                }
                ColumnText ct = new ColumnText(t);
                ct.setRunDirection(runDirection);
                ct.setSimpleColumn(new Phrase(text, font), dataRect.getLeft(), dataRect.getBottom(), dataRect.getRight(), dataRect.getTop(), size, Element.ALIGN_LEFT);
                ct.go();
            }
        }
        if (app[3] == null && !acro6Layers) {
            PdfTemplate t = app[3] = new PdfTemplate(writer);
            t.setBoundingBox(new Rectangle(100, 100));
            writer.addDirectTemplateSimple(t, new PdfName("n3"));
            t.setLiteral("% DSBlank\n");
        }
        if (app[4] == null && !acro6Layers) {
            PdfTemplate t = app[4] = new PdfTemplate(writer);
            t.setBoundingBox(new Rectangle(0, rect.getHeight() * (1 - TOP_SECTION), rect.getRight(), rect.getTop()));
            writer.addDirectTemplateSimple(t, new PdfName("n4"));
            Font font;
            if (layer2Font == null)
                font = new Font();
            else
                font = new Font(layer2Font);
            float size = font.getSize();
            String text = "Signature Not Verified";
            if (layer4Text != null)
                text = layer4Text;
            Rectangle sr = new Rectangle(rect.getWidth() - 2 * MARGIN, rect.getHeight() * TOP_SECTION - 2 * MARGIN);
            size = fitText(font, text, sr, 15, runDirection);
            ColumnText ct = new ColumnText(t);
            ct.setRunDirection(runDirection);
            ct.setSimpleColumn(new Phrase(text, font), MARGIN, 0, rect.getWidth() - MARGIN, rect.getHeight() - MARGIN, size, Element.ALIGN_LEFT);
            ct.go();
        }
        int rotation = writer.reader.getPageRotation(page);
        Rectangle rotated = new Rectangle(rect);
        int n = rotation;
View Full Code Here

                }
                int minLines = Math.max(cr, lf) + 1;
                maxFontSize = Math.abs(rect.getHeight()) / minLines - 0.001f;
            }
            font.setSize(maxFontSize);
            Phrase ph = new Phrase(text, font);
            ct = new ColumnText(null);
            ct.setSimpleColumn(ph, rect.getLeft(), rect.getBottom(), rect.getRight(), rect.getTop(), maxFontSize, Element.ALIGN_LEFT);
            ct.setRunDirection(runDirection);
            status = ct.go(true);
            if ((status & ColumnText.NO_MORE_TEXT) != 0)
                return maxFontSize;
            float precision = 0.1f;
            float min = 0;
            float max = maxFontSize;
            float size = maxFontSize;
            for (int k = 0; k < 50; ++k) { //just in case it doesn't converge
                size = (min + max) / 2;
                ct = new ColumnText(null);
                font.setSize(size);
                ct.setSimpleColumn(new Phrase(text, font), rect.getLeft(), rect.getBottom(), rect.getRight(), rect.getTop(), size, Element.ALIGN_LEFT);
                ct.setRunDirection(runDirection);
                status = ct.go(true);
                if ((status & ColumnText.NO_MORE_TEXT) != 0) {
                    if (max - min < size * precision)
                        return size;
View Full Code Here

     * Adds a cell element.
     *
     * @param text the text for the cell
     */
    public void addCell(final String text) {
        addCell(new Phrase(text));
    }
View Full Code Here

        char cc[] = text.toCharArray();
        int len = cc.length;
        StringBuffer sb = new StringBuffer();
        Font font = null;
        int lastidx = -1;
        Phrase ret = new Phrase();
        for (int k = 0; k < len; ++k) {
            char c = cc[k];
            if (c == '\n' || c == '\r') {
                sb.append(c);
                continue;
            }
            if (Utilities.isSurrogatePair(cc, k)) {
                int u = Utilities.convertToUtf32(cc, k);
                for (int f = 0; f < fsize; ++f) {
                    font = fonts.get(f);
                    if (font.getBaseFont().charExists(u)) {
                        if (lastidx != f) {
                            if (sb.length() > 0 && lastidx != -1) {
                                Chunk ck = new Chunk(sb.toString(), fonts.get(lastidx));
                                ret.add(ck);
                                sb.setLength(0);
                            }
                            lastidx = f;
                        }
                        sb.append(c);
                        sb.append(cc[++k]);
                        break;
                    }
                }
            }
            else {
                for (int f = 0; f < fsize; ++f) {
                    font = fonts.get(f);
                    if (font.getBaseFont().charExists(c)) {
                        if (lastidx != f) {
                            if (sb.length() > 0 && lastidx != -1) {
                                Chunk ck = new Chunk(sb.toString(), fonts.get(lastidx));
                                ret.add(ck);
                                sb.setLength(0);
                            }
                            lastidx = f;
                        }
                        sb.append(c);
                        break;
                    }
                }
            }
        }
        if (sb.length() > 0) {
            Chunk ck = new Chunk(sb.toString(), fonts.get(lastidx == -1 ? 0 : lastidx));
            ret.add(ck);
        }
        return ret;
    }
View Full Code Here

        for (PdfLine l: lines) {
            float moveTextX = l.indentLeft() - indentLeft() + indentation.indentLeft + indentation.listIndentLeft + indentation.sectionIndentLeft;
            text.moveText(moveTextX, -l.height());
            // is the line preceded by a symbol?
            if (l.listSymbol() != null) {
                ColumnText.showTextAligned(graphics, Element.ALIGN_LEFT, new Phrase(l.listSymbol()), text.getXTLM() - l.listIndent(), text.getYTLM(), 0);
            }

            currentValues[0] = currentFont;

            writeLineToContent(l, text, graphics, currentValues, writer.getSpaceCharRatio());
View Full Code Here

            this.image = image;
            column.setLeading(0, 1);
            setPadding(borderWidth / 2);
        }
        else {
            column.addText(this.phrase = new Phrase(new Chunk(image, 0, 0)));
            column.setLeading(0, 1);
            setPadding(0);
        }
    }
View Full Code Here

      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);
      header1.addCell(cell);
      header1.setTotalWidth(document.getPageSize().getWidth() - document.leftMargin() - document.rightMargin());
      document.add(header1);
View Full Code Here

      }
    }
    // 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

TOP

Related Classes of com.itextpdf.text.Phrase

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.