Package com.itextpdf.text

Examples of com.itextpdf.text.Chunk


    protected void buildConclusions(Analysis analysis, Report report) throws DocumentException {
        Font titleFont = new Font(fontMapper.awtToPdf(this.reportSettingsProperties.loadBodyTextTitleFont()));
        Font textFont = new Font(fontMapper.awtToPdf(this.reportSettingsProperties.loadBodyTextFont()));

        if ((report.getComments() != null) && (!report.getComments().isEmpty())) {
            Chunk coment = new Chunk(EntityDescriptions.COMMENTS + ":" + System.getProperty("line.separator"));
            coment.setFont(titleFont);
            this.document.add(coment);
            Chunk coments = new Chunk(report.getComments());
            coments.setFont(textFont);
            this.document.add(coments);
            this.writeEmptyLine();
        }

        boolean iarEmpty = ((report.getCommentIAR() == null) || (report.getCommentIAR().isEmpty()));
        boolean aosEmpty = (report.getCommentAOS() == null) || (report.getCommentAOS().isEmpty());
        boolean aodEmpty = ((report.getCommentAOD() == null) || (report.getCommentAOD().isEmpty()));

        if ((!iarEmpty) || (!aodEmpty) || (!aosEmpty)) {

            Chunk indice = new Chunk(EntityDescriptions.INDEXS + ":" + System.getProperty("line.separator"));
            indice.setFont(titleFont);
            this.document.add(indice);
            this.document.add(new Paragraph());

            int samples = 0;
            try {
                AverageByDecade averageByDecade = FacadeDB.getInstance().getAveragesBroker().getAverageByPatient(analysis.getPatient());
                if (averageByDecade != null) {
                    samples = averageByDecade.getSamples();
                }
            } catch (ExceptionDAO aO) {
                //
            }

            Chunk detail = new Chunk(ReportTexts.ideal_characteristics + System.getProperty("line.separator")
                    + ReportTexts.values_to + analysis.getPatient().getDecade() + ReportTexts.decade_and_averages + String.valueOf(samples) + System.getProperty("line.separator"));
            Font detailFont = new Font(fontMapper.awtToPdf(this.reportSettingsProperties.loadBodyTextFont().deriveFont(Font.ITALIC, textFont.getSize() - 2)));
            detail.setFont(detailFont);

            this.document.add(detail);

            if (!iarEmpty) {
                Chunk indiceIAR = new Chunk(report.getCommentIAR() + System.getProperty("line.separator"));
                indiceIAR.setFont(textFont);
                this.document.add(indiceIAR);
            }

            if (!aosEmpty) {
                Chunk indiceAOS = new Chunk(report.getCommentAOS() + System.getProperty("line.separator"));
                indiceAOS.setFont(textFont);
                this.document.add(indiceAOS);
            }

            if (!aodEmpty) {
                Chunk indiceAOD = new Chunk(report.getCommentAOD() + System.getProperty("line.separator"));
                indiceAOD.setFont(textFont);
                this.document.add(indiceAOD);
            }
            this.writeEmptyLine();
        }

        if ((report.getAllBackground() != null) && (!report.getAllBackground().isEmpty())) {

            Chunk antedecente = new Chunk(EntityDescriptions.BACKGROUNDS + ":" + System.getProperty("line.separator"));
            antedecente.setFont(titleFont);
            this.document.add(antedecente);

            Chunk antecedentes = new Chunk(report.getAllBackground());
            antecedentes.setFont(textFont);
            this.document.add(antecedentes);

            this.writeEmptyLine();
        }

        if ((report.getConclusion() != null) && (!report.getConclusion().isEmpty())) {
            Chunk concluson = new Chunk(EntityDescriptions.CONCLUSION + ":" + System.getProperty("line.separator"));
            concluson.setFont(titleFont);
            this.document.add(concluson);
            Chunk conclusiones = new Chunk(report.getConclusion());
            conclusiones.setFont(textFont);
            this.document.add(conclusiones);
        }

    }
View Full Code Here


        return p;
    }

    public static PDFPhraseWrapper createLabelPhrase(String label, PDFFontWrapper pdfFontWrapper) {
        PDFPhraseWrapper p = createPhrase();
        Chunk chunk = org.openinvoice.ubl4j.core.common.text.pdf.common.PDFChunkWrapper.createLabelChunk(label).getChunk();
        chunk.setFont(pdfFontWrapper.getFont());
        p.phrase.add(chunk);
        return p;
    }
View Full Code Here

        return pdfChunkWrapper;
    }


    public PDFChunkWrapper(String s) {
        this.chunk = new Chunk(s);
    }
View Full Code Here

  }
  private void addTitle(final Document document) throws DocumentException {
    progress.setValue(10);
    final Paragraph from = new Paragraph(Config.getFrom(),getDefaultFont());
    from.setAlignment(Paragraph.ALIGN_CENTER);
    from.add(new Chunk("\n"));
      from.add(new Chunk(new LineSeparator(1f, 100f, BaseColor.BLACK, Element.ALIGN_CENTER, 0)));
      from.add(new Chunk("\n\n"));
      document.add(from);
     
      final PdfPTable table = new PdfPTable(2);
      final Paragraph invoice = new Paragraph("Invoice No", getDefaultBoldFont());
      final Paragraph invoiceValue = new Paragraph(this.invoiceNumber, getDefaultFont());
View Full Code Here

        for (int i = 0; i < pageContents.length; i++) {
            if (i != 0)
                document.newPage();

            String content = pageContents[i];
            Chunk contentChunk = new Chunk(content);
            document.add(contentChunk);
        }
       
       
        document.close();
View Full Code Here

                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

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

                // 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 Chunk get(final String e, final Font font) {
        char s = getCorrespondingSymbol(e);
        if (s == (char)0) {
            try {
                return new Chunk(String.valueOf((char)Integer.parseInt(e)), font);
            }
            catch(Exception exception) {
                return new Chunk(e, font);
            }
        }
        Font symbol = new Font(FontFamily.SYMBOL, font.getSize(), font.getStyle(), font.getColor());
        return new Chunk(String.valueOf(s), symbol);
    }
View Full Code Here

      if (content.trim().length() == 0 && content.indexOf(' ') < 0) {
        return;
      }
      content = HtmlUtilities.eliminateWhiteSpace(content);
    }
    Chunk chunk = createChunk(content);
    currentParagraph.add(chunk);
  }
View Full Code Here

TOP

Related Classes of com.itextpdf.text.Chunk

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.