Example usage for com.itextpdf.text Phrase add

List of usage examples for com.itextpdf.text Phrase add

Introduction

In this page you can find the example usage for com.itextpdf.text Phrase add.

Prototype

@Override
public boolean add(final Element element) 

Source Link

Document

Adds a Chunk, Anchor or another Phrase to this Phrase.

Usage

From source file:fll.web.report.FinalComputedScores.java

License:Open Source License

private PdfPTable createHeader(final String challengeTitle, final String tournamentName,
        final String division) {
    // initialization of the header table
    final PdfPTable header = new PdfPTable(2);

    final Phrase p = new Phrase();
    p.add(new Chunk(challengeTitle, TIMES_12PT_NORMAL));
    p.add(Chunk.NEWLINE);//w  w w.  j  a v  a  2  s  .  co  m
    p.add(new Chunk("Final Computed Scores", TIMES_12PT_NORMAL));
    header.getDefaultCell().setBorderWidth(0);
    header.addCell(p);
    header.getDefaultCell().setHorizontalAlignment(com.itextpdf.text.Element.ALIGN_RIGHT);

    final Phrase p2 = new Phrase();
    p2.add(new Chunk("Tournament: " + tournamentName, TIMES_12PT_NORMAL));
    p2.add(Chunk.NEWLINE);
    p2.add(new Chunk("Award Group: " + division, TIMES_12PT_NORMAL));
    header.addCell(p2);

    return header;
}

From source file:fll.web.report.ReportPageEventHandler.java

License:Open Source License

@Override
// initialization of the header table
public void onEndPage(final PdfWriter writer, final Document document) {
    final PdfPTable header = new PdfPTable(2);
    final Phrase p = new Phrase();
    final Chunk ck = new Chunk(_challengeTitle + "\n" + _reportTitle, _font);
    p.add(ck);
    header.getDefaultCell().setBorderWidth(0);
    header.addCell(p);//from   ww w.j  a  v  a2s .  c  o  m
    header.getDefaultCell().setHorizontalAlignment(com.itextpdf.text.Element.ALIGN_RIGHT);
    header.addCell(new Phrase(new Chunk("Tournament: " + _tournament + "\nDate: " + _formattedDate, _font)));
    final PdfPCell blankCell = new PdfPCell();
    blankCell.setBorder(0);
    blankCell.setBorderWidthTop(1.0f);
    blankCell.setColspan(2);
    header.addCell(blankCell);

    final PdfContentByte cb = writer.getDirectContent();
    cb.saveState();
    header.setTotalWidth(document.right() - document.left());
    header.writeSelectedRows(0, -1, document.left(), document.getPageSize().getHeight() - 10, cb);
    cb.restoreState();
}

From source file:jdbreport.model.io.pdf.itext5.PdfWriter.java

License:Apache License

protected void writeHTMLText(CellStyle parentStyle, jdbreport.model.Cell cell, PdfPCell pdfCell) {
    if (cell.isNull() || cell.isChild())
        return;/*ww w .j a  v a 2 s .c om*/

    JTextComponent tc = getHTMLReportRenderer();
    tc.setText(cell.getText());
    List<Content> contentList = Content.getHTMLContentList((HTMLDocument) tc.getDocument());
    if (contentList != null) {
        Phrase phrase = new Phrase();
        for (Content content : contentList) {
            CellStyle newStyle = content.createTextStyle(parentStyle, parentStyle);
            if (newStyle == null) {
                newStyle = parentStyle;
            }
            if (newStyle != null) {
                if (newStyle.getTypeOffset() == CellStyle.SS_SUPER
                        || newStyle.getTypeOffset() == CellStyle.SS_SUB) {
                    newStyle = newStyle.deriveFont((float) newStyle.getSize() / 2);
                }
                int i = textStyles.indexOf(newStyle);
                if (i < 0) {
                    textStyles.add(newStyle);
                    i = textStyles.size() - 1;
                }
                Font font;
                String styleId = "T" + (i + 1);
                if (fonts.containsKey(styleId)) {
                    font = fonts.get(styleId);
                } else {
                    font = getFontMapper().styleToPdf(newStyle);
                    fonts.put(styleId, font);
                }
                Chunk chunk = new Chunk(content.getText(), font);
                chunk.setBackground(new BaseColor(newStyle.getBackground().getRGB()));
                if (newStyle.getTypeOffset() == CellStyle.SS_SUPER) {
                    chunk.setTextRise(newStyle.getSize() / 2);
                } else if (newStyle.getTypeOffset() == CellStyle.SS_SUB) {
                    chunk.setTextRise(-newStyle.getSize() / 2);
                }
                phrase.add(chunk);
            } else {
                phrase.add(new Chunk(content.getText()));
            }
        }
        pdfCell.setPhrase(phrase);
    }
}

From source file:main.ItextPDF.java

public void createPdf(String filename, Person person) {
    // step 1//from   w w w  .  j  a  v  a 2s  . c  o m
    Document document = new Document();
    // step 2
    try {
        PdfWriter.getInstance(document, new FileOutputStream(filename));
        // step 3
        document.open();

        BaseFont bf_ru = BaseFont.createFont(FONT_RU, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
        Font font_ru = new Font(bf_ru, 10);
        BaseFont bf_ch = BaseFont.createFont(FONT_CH, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
        Font font_ch = new Font(bf_ch, 10);
        ResourceBundle rb_ch = ResourceBundle.getBundle("bundles/lang", Locale.CHINA);
        ResourceBundle rb_ru = ResourceBundle.getBundle("bundles/lang", Locale.GERMANY);
        //
        Paragraph preface = new Paragraph(rb_ch.getString("pdfFileheder1"), font_ch);
        preface.setAlignment(Element.ALIGN_CENTER);
        document.add(preface);

        preface = new Paragraph(rb_ru.getString("pdfFileheder1"), font_ru);
        preface.setAlignment(Element.ALIGN_CENTER);
        document.add(preface);
        document.add(new Phrase(rb_ch.getString("pdfFileheder2"), font_ch));
        document.add(new Phrase(rb_ru.getString("pdfFileheder2"), font_ru));
        Phrase pr = new Phrase("\n ");
        pr.add(new Phrase(rb_ch.getString("part1"), font_ch));
        pr.add(new Phrase(" "));
        pr.add(new Phrase(rb_ru.getString("part1"), font_ru));

        document.add(pr);

        PdfPTable basetable = new PdfPTable(2);
        basetable.setWidthPercentage(100);

        PdfPTable table1 = new PdfPTable(4);
        pr = new Phrase(rb_ch.getString("nameDesc"), font_ch);
        pr.add(new Phrase(" "));
        pr.add(new Phrase(rb_ru.getString("nameDesc"), font_ru));
        PdfPCell cell = new PdfPCell(pr);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell.setRowspan(3);
        table1.addCell(cell);

        //line 1
        //PdfPTable table2 = new PdfPTable(2);
        pr = new Phrase(rb_ch.getString("lastname"), font_ch);
        pr.add(new Phrase(" "));
        pr.add(new Phrase(rb_ru.getString("lastname"), font_ru));
        PdfPCell cell1 = new PdfPCell(pr);
        PdfPCell cell2 = new PdfPCell(new Paragraph(person.getField1()));
        cell2.setColspan(2);
        table1.addCell(cell1);
        table1.addCell(cell2);

        pr = new Phrase(rb_ch.getString("fathername"), font_ch);
        pr.add(new Phrase(" "));
        pr.add(new Phrase(rb_ru.getString("fathername"), font_ru));
        cell1 = new PdfPCell(pr);
        cell2 = new PdfPCell(new Paragraph(person.getField2()));
        table1.addCell(cell1);
        cell2.setColspan(2);
        table1.addCell(cell2);

        pr = new Phrase(rb_ch.getString("firstname"), font_ch);
        pr.add(new Phrase(" "));
        pr.add(new Phrase(rb_ru.getString("firstname"), font_ru));
        cell1 = new PdfPCell(pr);
        cell2 = new PdfPCell(new Paragraph(person.getField3()));
        table1.addCell(cell1);
        cell2.setColspan(2);
        table1.addCell(cell2);
        //basetable.addCell(table1);
        //basetable.addCell(table2);
        ///line 2 1.2 1.3
        //table1 = new PdfPTable(4);

        pr = new Phrase(rb_ch.getString("chinaseName"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("chinaseName"), font_ru));
        cell1 = new PdfPCell(pr);
        cell2 = new PdfPCell(new Paragraph(person.getField4()));
        table1.addCell(cell1);
        table1.addCell(cell2);

        pr = new Phrase(rb_ch.getString("othername"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("othername"), font_ru));
        cell1 = new PdfPCell(pr);
        cell2 = new PdfPCell(new Paragraph(person.getField5()));
        table1.addCell(cell1);
        table1.addCell(cell2);
        //1.4 1.5
        pr = new Phrase(rb_ch.getString("sex"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("sex"), font_ru));
        cell1 = new PdfPCell(pr);
        cell2 = new PdfPCell(new Paragraph(person.getField6() + " " + person.getField7()));
        table1.addCell(cell1);
        table1.addCell(cell2);
        pr = new Phrase(rb_ch.getString("databirth"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("databirth"), font_ru));
        cell1 = new PdfPCell(pr);
        pr = new Phrase();
        pr.add(new Phrase(person.getField8()));
        pr.add(new Phrase("/"));
        pr.add(new Phrase(person.getField9()));
        pr.add(new Phrase("/"));
        pr.add(new Phrase(person.getField10()));
        cell2 = new PdfPCell(pr);
        table1.addCell(cell1);
        table1.addCell(cell2);
        //1.6 1.7
        pr = new Phrase(rb_ch.getString("citizen"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("citizen"), font_ru));
        cell1 = new PdfPCell(pr);
        cell2 = new PdfPCell(new Paragraph(person.getField11()));
        table1.addCell(cell1);
        table1.addCell(cell2);
        pr = new Phrase(rb_ch.getString("old_citizen_of"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("old_citizen_of"), font_ru));
        cell1 = new PdfPCell(pr);
        cell2 = new PdfPCell(new Paragraph(person.getField12()));
        table1.addCell(cell1);
        table1.addCell(cell2);
        //1.8
        pr = new Phrase(rb_ch.getString("birthplace"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("birthplace"), font_ru));
        cell1 = new PdfPCell(pr);
        cell2 = new PdfPCell(new Paragraph(person.getField13()));
        cell1.setColspan(2);
        table1.addCell(cell1);
        cell2.setColspan(2);
        table1.addCell(cell2);
        //1.9
        pr = new Phrase(rb_ch.getString("passportData"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("passportData"), font_ru));
        cell1 = new PdfPCell(pr);
        cell2 = new PdfPCell(new Paragraph(person.getField14()));
        cell1.setColspan(2);
        table1.addCell(cell1);
        cell2.setColspan(2);
        table1.addCell(cell2);
        //1.10
        pr = new Phrase(rb_ch.getString("passportType"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("passportType"), font_ru));
        cell1 = new PdfPCell(pr);
        pr = new Phrase(person.getField15() + " " + person.getField16() + " " + person.getField17() + " "
                + person.getField18() + " " + person.getField19(), font_ru);
        cell2 = new PdfPCell(pr);
        cell1.setColspan(2);
        table1.addCell(cell1);
        cell2.setColspan(2);
        table1.addCell(cell2);
        //1.11 1.12
        pr = new Phrase(rb_ch.getString("passportNumber"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("passportNumber"), font_ru));
        cell1 = new PdfPCell(pr);
        cell2 = new PdfPCell(new Paragraph(person.getField20()));
        table1.addCell(cell1);
        table1.addCell(cell2);
        pr = new Phrase(rb_ch.getString("passportGivenDate"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("passportGivenDate"), font_ru));
        cell1 = new PdfPCell(pr);
        cell2 = new PdfPCell(
                new Paragraph(person.getField21() + "/" + person.getField22() + "/" + person.getField23()));
        table1.addCell(cell1);
        table1.addCell(cell2);
        //1.13 1.14
        pr = new Phrase(rb_ch.getString("passportGivenPlace"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("passportGivenPlace"), font_ru));
        cell1 = new PdfPCell(pr);
        cell2 = new PdfPCell(new Paragraph(person.getField24()));
        table1.addCell(cell1);
        table1.addCell(cell2);
        pr = new Phrase(rb_ch.getString("passportValidDate"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("passportValidDate"), font_ru));
        cell1 = new PdfPCell(pr);
        cell2 = new PdfPCell(
                new Paragraph(person.getField25() + "/" + person.getField26() + "/" + person.getField27()));
        table1.addCell(cell1);
        table1.addCell(cell2);
        //1.15
        pr = new Phrase(rb_ch.getString("passportProfession"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("passportProfession"), font_ru));
        cell1 = new PdfPCell(pr);
        /*cell2 = new PdfPCell(new Paragraph(
                person.getField28() + " " +
                person.getField29() + " " +
                person.getField30()
                ));*/
        table1.addCell(cell1);
        //table1.addCell(cell2);
        //cell2 = new PdfPCell(new Paragraph(rs.getString("FIELD" + 16)));
        PdfPTable innertable = new PdfPTable(2);
        innertable.setWidthPercentage(100);

        pr = new Phrase(rb_ch.getString("profession1"), font_ch);
        if (!person.getField28().equals("")) {
            pr.add(new Phrase("                                      "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("profession1"), font_ru));

        PdfPCell innercell = new PdfPCell(pr);

        //innercell.setBorder(Rectangle.BOTTOM);
        innertable.addCell(innercell);

        pr = new Phrase(rb_ch.getString("profession10"), font_ch);
        if (!person.getField37().equals("")) {
            pr.add(new Phrase("    "));
            pr.add(new Phrase(person.getField38(), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("profession10"), font_ru));
        innercell = new PdfPCell(pr);
        //innercell.setBorder(Rectangle.LEFT);
        innertable.addCell(innercell);

        pr = new Phrase(rb_ch.getString("profession2"), font_ch);
        if (!person.getField29().equals("")) {
            pr.add(new Phrase("                             "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("profession2"), font_ru));
        innercell = new PdfPCell(pr);
        //innercell.setBorder(Rectangle.BOTTOM);
        innertable.addCell(innercell);

        pr = new Phrase(rb_ch.getString("profession11"), font_ch);
        if (!person.getField39().equals("")) {
            pr.add(new Phrase("    "));
            pr.add(new Phrase(person.getField40(), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("profession11"), font_ru));
        innercell = new PdfPCell(pr);
        //innercell.setBorder(Rectangle.LEFT);
        innertable.addCell(innercell);

        pr = new Phrase(rb_ch.getString("profession3"), font_ch);
        if (!person.getField30().equals("")) {
            pr.add(new Phrase("                             "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("profession3"), font_ru));
        innercell = new PdfPCell(pr);
        //innercell.setBorder(Rectangle.RIGHT);
        innertable.addCell(innercell);

        pr = new Phrase(rb_ch.getString("profession12"), font_ch);
        if (!person.getField41().equals("")) {
            pr.add(new Phrase("    "));
            pr.add(new Phrase(person.getField42(), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("profession12"), font_ru));
        innercell = new PdfPCell(pr);
        //innercell.setBorder(Rectangle.NO_BORDER);
        innertable.addCell(innercell);

        pr = new Phrase(rb_ch.getString("profession4"), font_ch);
        if (!person.getField31().equals("")) {
            pr.add(new Phrase("                           "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("profession4"), font_ru));
        innercell = new PdfPCell(pr);
        //innercell.setBorder(Rectangle.RIGHT);
        innertable.addCell(innercell);

        pr = new Phrase(rb_ch.getString("profession13"), font_ch);
        if (!person.getField43().equals("")) {
            pr.add(new Phrase("                              "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("profession13"), font_ru));
        innercell = new PdfPCell(pr);
        //innercell.setBorder(Rectangle.NO_BORDER);
        innertable.addCell(innercell);

        pr = new Phrase(rb_ch.getString("profession5"), font_ch);
        if (!person.getField32().equals("")) {
            pr.add(new Phrase("                                      "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("profession5"), font_ru));
        innercell = new PdfPCell(pr);
        //innercell.setBorder(Rectangle.RIGHT);
        innertable.addCell(innercell);

        pr = new Phrase(rb_ch.getString("profession14"), font_ch);
        if (!person.getField44().equals("")) {
            pr.add(new Phrase("                                          "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("profession14"), font_ru));
        innercell = new PdfPCell(pr);
        //innercell.setBorder(Rectangle.NO_BORDER);
        innertable.addCell(innercell);

        pr = new Phrase(rb_ch.getString("profession6"), font_ch);
        if (!person.getField33().equals("")) {
            pr.add(new Phrase("                              "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }

        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("profession6"), font_ru));
        innertable.addCell(pr);

        pr = new Phrase(rb_ch.getString("profession15"), font_ch);
        if (!person.getField45().equals("")) {
            pr.add(new Phrase("                                 "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("profession15"), font_ru));
        innertable.addCell(pr);

        pr = new Phrase(rb_ch.getString("profession7"), font_ch);
        if (!person.getField34().equals("")) {
            pr.add(new Phrase("                                        "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("profession7"), font_ru));
        innertable.addCell(pr);

        pr = new Phrase("");
        innertable.addCell(pr);

        pr = new Phrase(rb_ch.getString("profession8"), font_ch);
        if (!person.getField35().equals("")) {
            pr.add(new Phrase("                                        "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("profession8"), font_ru));
        innertable.addCell(pr);
        pr = new Phrase("");
        innertable.addCell(pr);

        pr = new Phrase(rb_ch.getString("profession9"), font_ch);
        if (!person.getField36().equals("")) {
            pr.add(new Phrase("                                        "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("profession9"), font_ru));
        innertable.addCell(pr);
        pr = new Phrase("");
        innertable.addCell(pr);

        pr = new Phrase(rb_ch.getString("profession16"), font_ch);
        if (!person.getField173().equals("")) {
            pr.add(new Phrase("                                        "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase(person.getField174(), font_ru));
            pr.add(new Phrase("\n"));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("profession16"), font_ru));
        innertable.addCell(pr);
        pr = new Phrase("");
        innertable.addCell(pr);

        cell2.setColspan(3);
        cell2.addElement(innertable);
        table1.addCell(cell2);
        //1.16
        pr = new Phrase(rb_ch.getString("education"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("education"), font_ru));
        cell1 = new PdfPCell(pr);
        cell2 = new PdfPCell(new Paragraph(""));
        cell1.setColspan(1);
        table1.addCell(cell1);

        innertable = new PdfPTable(2);
        innertable.setWidthPercentage(100);

        pr = new Phrase(rb_ch.getString("education1"), font_ch);
        if (!person.getField46().equals("")) {
            pr.add(new Phrase("                                   "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("education1"), font_ru));
        innertable.addCell(pr);

        pr = new Phrase(rb_ch.getString("education2"), font_ch);
        if (!person.getField47().equals("")) {
            pr.add(new Phrase("                                              "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("education2"), font_ru));
        innertable.addCell(pr);

        pr = new Phrase(rb_ch.getString("education3"), font_ch);
        if (!person.getField48().equals("")) {
            pr.add(new Phrase("           "));
            pr.add(new Phrase(person.getField49(), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("education3"), font_ru));
        innertable.addCell(pr);

        innertable.addCell(new Phrase());

        cell2.setColspan(3);
        cell2.addElement(innertable);
        table1.addCell(cell2);
        //1.17
        pr = new Phrase(rb_ch.getString("workPlace"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("workPlace"), font_ru));
        cell1 = new PdfPCell(pr);
        cell2 = new PdfPCell(new Paragraph(""));
        cell1.setColspan(1);
        table1.addCell(cell1);

        innertable = new PdfPTable(2);
        innertable.setWidthPercentage(100);

        pr = new Phrase(rb_ch.getString("workPlace1"), font_ch);
        if (!person.getField50().equals("")) {
            pr.add(new Phrase("    "));
            pr.add(new Phrase(person.getField50(), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("workPlace1"), font_ru));
        innertable.addCell(pr);

        pr = new Phrase(rb_ch.getString("workPlace2"), font_ch);
        if (!person.getField51().equals("")) {
            pr.add(new Phrase("    "));
            pr.add(new Phrase(person.getField51(), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("workPlace2"), font_ru));
        innertable.addCell(pr);

        pr = new Phrase(rb_ch.getString("workPlace3"), font_ch);
        if (!person.getField52().equals("")) {
            pr.add(new Phrase("    "));
            pr.add(new Phrase(person.getField52(), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("workPlace3"), font_ru));
        innertable.addCell(pr);

        pr = new Phrase(rb_ch.getString("workPlace4"), font_ch);
        if (!person.getField53().equals("")) {
            pr.add(new Phrase("    "));
            pr.add(new Phrase(person.getField53(), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("workPlace4"), font_ru));
        innertable.addCell(pr);

        cell2.setColspan(3);
        cell2.addElement(innertable);
        table1.addCell(cell2);
        //
        PdfPCell tcell = new PdfPCell(table1);
        tcell.setColspan(2);
        basetable.addCell(tcell);
        //
        document.add(basetable);

        //////////////////////////////////////////////////////////page2
        basetable = new PdfPTable(2);
        basetable.setWidthPercentage(100);
        table1 = new PdfPTable(4);
        //1.18 1.19
        pr = new Phrase(rb_ch.getString("homeAddr"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("homeAddr"), font_ru));
        cell1 = new PdfPCell(pr);
        pr = new Paragraph("");
        if (!person.getField54().equals("")) {
            pr.add(new Phrase(person.getField54(), font_ru));
        }
        cell2 = new PdfPCell(pr);
        table1.addCell(cell1);
        table1.addCell(cell2);
        pr = new Phrase(rb_ch.getString("zipCode"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("zipCode"), font_ru));
        cell1 = new PdfPCell(pr);
        pr = new Paragraph("");
        if (!person.getField55().equals("")) {
            pr.add(new Phrase(person.getField55(), font_ru));
        }
        cell2 = new PdfPCell(pr);
        table1.addCell(cell1);
        table1.addCell(cell2);
        //1.20 1.21
        pr = new Phrase(rb_ch.getString("phoneNum"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("phoneNum"), font_ru));
        cell1 = new PdfPCell(pr);
        pr = new Paragraph("");
        if (!person.getField56().equals("")) {
            pr.add(new Phrase(person.getField56(), font_ru));
        }
        cell2 = new PdfPCell(pr);
        table1.addCell(cell1);
        table1.addCell(cell2);
        pr = new Phrase(rb_ch.getString("email"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("email"), font_ru));
        cell1 = new PdfPCell(pr);
        pr = new Paragraph("");
        if (!person.getField57().equals("")) {
            pr.add(new Phrase(person.getField57(), font_ru));
        }
        cell2 = new PdfPCell(pr);
        table1.addCell(cell1);
        table1.addCell(cell2);
        //1.22
        pr = new Phrase(rb_ch.getString("familyStatus"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("familyStatus"), font_ru));
        cell1 = new PdfPCell(pr);
        table1.addCell(cell1);
        pr = new Phrase(" ");
        if (!person.getField66().equals("")) {
            pr.add(new Phrase(rb_ru.getString("familyStatus1"), font_ru));
            pr.add(new Phrase(" "));
        }
        if (!person.getField67().equals("")) {
            pr.add(new Phrase(rb_ru.getString("familyStatus2"), font_ru));
            pr.add(new Phrase(" "));
        }
        if (!person.getField68().equals("")) {
            pr.add(new Phrase(rb_ru.getString("familyStatus3"), font_ru));
            pr.add(new Phrase(" "));
            pr.add(new Phrase(person.getField69(), font_ru));
        }
        cell2 = new PdfPCell(pr);
        cell2.setColspan(3);
        table1.addCell(cell2);

        /*tcell = new PdfPCell(table1);
        tcell.setColspan(2);
        basetable.addCell(tcell);*/
        //1.23
        pr = new Phrase(rb_ch.getString("familyStaff"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("familyStaff"), font_ru));
        cell1 = new PdfPCell(pr);
        table1.addCell(cell1);

        innertable = new PdfPTable(4);
        innertable.setWidthPercentage(100);
        pr = new Phrase(rb_ch.getString("familyStaff1"), font_ch);
        pr.add(new Phrase(" "));
        pr.add(new Phrase(rb_ru.getString("familyStaff1"), font_ru));
        innertable.addCell(pr);

        pr = new Phrase(rb_ch.getString("familyStaff2"), font_ch);
        pr.add(new Phrase(" "));
        pr.add(new Phrase(rb_ru.getString("familyStaff2"), font_ru));
        innertable.addCell(pr);

        pr = new Phrase(rb_ch.getString("familyStaff3"), font_ch);
        pr.add(new Phrase(" "));
        pr.add(new Phrase(rb_ru.getString("familyStaff3"), font_ru));
        innertable.addCell(pr);

        pr = new Phrase(rb_ch.getString("familyStaff4"), font_ch);
        pr.add(new Phrase(" "));
        pr.add(new Phrase(rb_ru.getString("familyStaff4"), font_ru));
        innertable.addCell(pr);

        //add 4 empty row
        //for(int l =0 ; l < 16; l++){
        innertable.addCell(new Phrase(person.getField58(), font_ru));
        innertable.addCell(new Phrase(person.getField59(), font_ru));
        innertable.addCell(new Phrase(person.getField60(), font_ru));
        innertable.addCell(new Phrase(person.getField61(), font_ru));

        innertable.addCell(new Phrase(person.getField62(), font_ru));
        innertable.addCell(new Phrase(person.getField63(), font_ru));
        innertable.addCell(new Phrase(person.getField64(), font_ru));
        innertable.addCell(new Phrase(person.getField65(), font_ru));

        innertable.addCell(new Phrase(person.getField66(), font_ru));
        innertable.addCell(new Phrase(person.getField67(), font_ru));
        innertable.addCell(new Phrase(person.getField68(), font_ru));
        innertable.addCell(new Phrase(person.getField69(), font_ru));

        innertable.addCell(new Phrase(person.getField70(), font_ru));
        innertable.addCell(new Phrase(person.getField71(), font_ru));
        innertable.addCell(new Phrase(person.getField72(), font_ru));
        innertable.addCell(new Phrase(person.getField73(), font_ru));
        //}

        tcell = new PdfPCell(innertable);
        tcell.setColspan(3);
        table1.addCell(tcell);
        //1.24
        pr = new Phrase(rb_ch.getString("contactPerson"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("contactPerson"), font_ru));
        cell1 = new PdfPCell(pr);
        table1.addCell(cell1);

        innertable = new PdfPTable(2);
        innertable.setWidthPercentage(100);
        pr = new Phrase(rb_ch.getString("contactPerson1"), font_ch);
        if (!person.getField74().equals("")) {
            pr.add(new Phrase("    "));
            pr.add(new Phrase(person.getField74(), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("contactPerson1"), font_ru));
        innertable.addCell(pr);

        pr = new Phrase(rb_ch.getString("contactPerson2"), font_ch);
        if (!person.getField75().equals("")) {
            pr.add(new Phrase("    "));
            pr.add(new Phrase(person.getField75(), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("contactPerson2"), font_ru));
        innertable.addCell(pr);

        pr = new Phrase(rb_ch.getString("contactPerson3"), font_ch);
        if (!person.getField76().equals("")) {
            pr.add(new Phrase("    "));
            pr.add(new Phrase(person.getField76(), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("contactPerson3"), font_ru));
        innertable.addCell(pr);

        pr = new Phrase(" ");
        innertable.addCell(pr);

        tcell = new PdfPCell(innertable);
        tcell.setColspan(3);
        table1.addCell(tcell);
        //1.25
        pr = new Phrase(rb_ch.getString("visitedPlace"), font_ch);
        pr.add(new Phrase(" "));
        pr.add(new Phrase(rb_ru.getString("visitedPlace"), font_ru));
        cell1 = new PdfPCell(pr);
        cell1.setColspan(2);
        table1.addCell(cell1);

        pr = new Phrase("");
        if (!person.getField77().equals("")) {
            pr.add(new Phrase("    "));
            pr.add(new Phrase(person.getField77(), font_ru));
        }
        cell2 = new PdfPCell(pr);
        cell2.setColspan(2);
        table1.addCell(cell2);

        //
        tcell = new PdfPCell(table1);
        tcell.setColspan(2);
        basetable.addCell(tcell);
        //////////////////////////////////////////////

        document.add(basetable);

        ///////////////////////////////////////part2
        pr = new Phrase("\n");
        pr.add(new Phrase(rb_ch.getString("part2Title"), font_ch));
        pr.add(new Phrase(" "));
        pr.add(new Phrase(rb_ru.getString("part2Title"), font_ru));
        pr.add(new Phrase("\n"));
        document.add(pr);
        //2.1
        basetable = new PdfPTable(2);
        basetable.setWidthPercentage(100);
        table1 = new PdfPTable(2);
        table1.setWidths(new int[] { 1, 5 });

        pr = new Phrase(rb_ch.getString("travelPurpose"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("travelPurpose"), font_ru));
        cell1 = new PdfPCell(pr);
        cell1.setRowspan(6);
        table1.addCell(cell1);

        innertable = new PdfPTable(2);
        innertable.setWidthPercentage(100);

        pr = new Phrase(rb_ch.getString("travelPurpose1"), font_ch);

        if (!person.getField78().equals("")) {
            pr.add(new Phrase("                                               "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("travelPurpose1"), font_ru));
        innertable.addCell(pr);

        pr = new Phrase(rb_ch.getString("travelPurpose8"), font_ch);
        if (!person.getField79().equals("")) {
            pr.add(new Phrase("                                    "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("travelPurpose8"), font_ru));
        innertable.addCell(pr);

        pr = new Phrase(rb_ch.getString("travelPurpose2"), font_ch);
        if (!person.getField80().equals("")) {
            pr.add(new Phrase("                                                       "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("travelPurpose2"), font_ru));
        innertable.addCell(pr);

        pr = new Phrase(rb_ch.getString("travelPurpose9"), font_ch);
        if (!person.getField82().equals("")) {
            pr.add(new Phrase("                                         "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("travelPurpose9"), font_ru));
        innertable.addCell(pr);

        pr = new Phrase(rb_ch.getString("travelPurpose3"), font_ch);
        if (!person.getField81().equals("")) {
            pr.add(new Phrase("                              "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("travelPurpose3"), font_ru));
        innertable.addCell(pr);

        pr = new Phrase(rb_ch.getString("travelPurpose10"), font_ch);
        if (!person.getField84().equals("")) {
            pr.add(new Phrase("                                              "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("travelPurpose10"), font_ru));
        innertable.addCell(pr);

        pr = new Phrase(rb_ch.getString("travelPurpose4"), font_ch);
        if (!person.getField83().equals("")) {
            pr.add(new Phrase("                                              "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("travelPurpose4"), font_ru));
        innertable.addCell(pr);

        pr = new Phrase(rb_ch.getString("travelPurpose11"), font_ch);
        if (!person.getField86().equals("")) {
            pr.add(new Phrase("                                              "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("travelPurpose11"), font_ru));
        innertable.addCell(pr);

        pr = new Phrase(rb_ch.getString("travelPurpose5"), font_ch);
        if (!person.getField85().equals("")) {
            pr.add(new Phrase("                                              "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("travelPurpose5"), font_ru));
        innertable.addCell(pr);
        innertable.addCell(new Phrase(" "));

        pr = new Phrase(rb_ch.getString("travelPurpose6"), font_ch);

        if (!person.getField87().equals("")) {
            pr.add(new Phrase("                                              "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("travelPurpose6"), font_ru));
        innertable.addCell(pr);
        innertable.addCell(new Phrase(" "));

        pr = new Phrase(rb_ch.getString("travelPurpose7"), font_ch);

        if (!person.getField88().equals("")) {
            pr.add(new Phrase("                                                      "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("travelPurpose7"), font_ru));
        innertable.addCell(pr);
        innertable.addCell(new Phrase(" "));

        innertable.addCell(new Phrase());
        cell2.addElement(innertable);
        table1.addCell(cell2);
        //
        innertable = new PdfPTable(2);
        innertable.setWidthPercentage(100);

        pr = new Phrase(rb_ch.getString("travelPurpose12"), font_ch);
        if (!person.getField89().equals("")) {
            pr.add(new Phrase("                                                      "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("travelPurpose12"), font_ru));
        innertable.addCell(pr);

        pr = new Phrase(rb_ch.getString("travelPurpose13"), font_ch);
        if (!person.getField90().equals("")) {
            pr.add(new Phrase("                                                      "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("travelPurpose13"), font_ru));
        innertable.addCell(pr);
        /*for(int j=12; j < 14; j++){
            pr = new Phrase(rb_ch.getString("travelPurpose"+j), font_ch);
            pr.add(new Phrase(" "));
            pr.add(new Phrase(rb_ru.getString("travelPurpose"+j), font_ru));
            innertable.addCell(pr);
        }*/
        cell2 = new PdfPCell(new Phrase(""));
        cell2.addElement(innertable);
        table1.addCell(cell2);
        //
        innertable = new PdfPTable(2);
        innertable.setWidthPercentage(100);

        /*for(int j=14; j < 16; j++){
            pr = new Phrase(rb_ch.getString("travelPurpose"+j), font_ch);
            pr.add(new Phrase(" "));
            pr.add(new Phrase(rb_ru.getString("travelPurpose"+j), font_ru));
            innertable.addCell(pr);
        }*/
        pr = new Phrase(rb_ch.getString("travelPurpose14"), font_ch);
        if (!person.getField91().equals("")) {
            pr.add(new Phrase("                                                      "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("travelPurpose14"), font_ru));
        innertable.addCell(pr);

        pr = new Phrase(rb_ch.getString("travelPurpose15"), font_ch);
        if (!person.getField92().equals("")) {
            pr.add(new Phrase("                                                      "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("travelPurpose15"), font_ru));
        innertable.addCell(pr);

        cell2 = new PdfPCell(new Phrase(""));
        cell2.addElement(innertable);
        table1.addCell(cell2);
        //
        innertable = new PdfPTable(2);
        innertable.setWidthPercentage(100);

        pr = new Phrase(rb_ch.getString("travelPurpose16"), font_ch);
        if (!person.getField93().equals("")) {
            pr.add(new Phrase("                                                      "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("travelPurpose16"), font_ru));
        innertable.addCell(pr);

        pr = new Phrase(rb_ch.getString("travelPurpose17"), font_ch);
        if (!person.getField94().equals("")) {
            pr.add(new Phrase("                                                      "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("travelPurpose17"), font_ru));
        innertable.addCell(pr);
        /*for(int j=16; j < 18; j++){
            pr = new Phrase(rb_ch.getString("travelPurpose"+j), font_ch);
            pr.add(new Phrase(" "));
            pr.add(new Phrase(rb_ru.getString("travelPurpose"+j), font_ru));
            innertable.addCell(pr);
        }*/
        cell2 = new PdfPCell(new Phrase(""));
        cell2.addElement(innertable);
        table1.addCell(cell2);
        //
        innertable = new PdfPTable(2);
        innertable.setWidthPercentage(100);

        /*for(int j=18; j < 20; j++){
            pr = new Phrase(rb_ch.getString("travelPurpose"+j), font_ch);
            pr.add(new Phrase(" "));
            pr.add(new Phrase(rb_ru.getString("travelPurpose"+j), font_ru));
            innertable.addCell(pr);
        }*/
        pr = new Phrase(rb_ch.getString("travelPurpose18"), font_ch);
        if (!person.getField95().equals("")) {
            pr.add(new Phrase("                                                      "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("travelPurpose18"), font_ru));
        innertable.addCell(pr);

        pr = new Phrase(rb_ch.getString("travelPurpose19"), font_ch);
        if (!person.getField96().equals("")) {
            pr.add(new Phrase("                                                      "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("travelPurpose19"), font_ru));
        innertable.addCell(pr);

        cell2 = new PdfPCell(new Phrase(""));
        cell2.addElement(innertable);
        table1.addCell(cell2);
        //
        innertable = new PdfPTable(2);
        innertable.setWidthPercentage(100);

        pr = new Phrase(rb_ch.getString("travelPurpose20"), font_ch);
        if (!person.getField97().equals("")) {
            pr.add(new Phrase("          "));
            pr.add(new Phrase(person.getField98(), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("travelPurpose20"), font_ru));
        PdfPCell innerCell2 = new PdfPCell(pr);
        innerCell2.setColspan(2);
        innertable.addCell(innerCell2);

        cell2 = new PdfPCell(new Phrase(""));
        cell2.addElement(innertable);
        table1.addCell(cell2);
        ///2.2
        pr = new Phrase(rb_ch.getString("planingTravel"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("planingTravel"), font_ru));
        cell1 = new PdfPCell(pr);
        table1.addCell(cell1);

        pr = new Phrase(rb_ch.getString("planingTravel1"), font_ch);
        if (!person.getField99().equals("")) {
            pr.add(new Phrase("                                                                 "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("planingTravel1"), font_ru));
        pr.add(new Phrase("\n \n"));

        pr.add(new Phrase(rb_ch.getString("planingTravel2"), font_ch));
        if (!person.getField100().equals("")) {
            pr.add(new Phrase("                                                           "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("planingTravel2"), font_ru));
        pr.add(new Phrase("\n \n"));

        pr.add(new Phrase(rb_ch.getString("planingTravel3"), font_ch));
        if (!person.getField101().equals("")) {
            pr.add(new Phrase("                                                      "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("planingTravel3"), font_ru));
        pr.add(new Phrase("\n \n"));

        pr.add(new Phrase(rb_ch.getString("planingTravel4"), font_ch));
        if (!person.getField102().equals("")) {
            pr.add(new Phrase("                                                        "));
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("planingTravel4"), font_ru));
        pr.add(new Phrase("\n \n"));

        pr.add(new Phrase(rb_ch.getString("planingTravel5"), font_ch));
        if (!person.getField103().equals("")) {
            pr.add(new Phrase("                   "));
            pr.add(new Phrase(person.getField104(), font_ch));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("planingTravel5"), font_ru));
        pr.add(new Phrase("\n \n"));
        cell2 = new PdfPCell(pr);

        table1.addCell(cell2);

        tcell = new PdfPCell(table1);
        tcell.setColspan(2);
        basetable.addCell(tcell);
        /////////////////////////////////////
        table1 = new PdfPTable(2);
        table1.setWidths(new int[] { 4, 1 });
        pr = new Phrase(rb_ch.getString("fastService"), font_ch);
        pr.add(new Phrase(" "));
        pr.add(new Phrase(rb_ru.getString("fastService"), font_ru));
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ch.getString("fastService2"), font_ch));
        pr.add(new Phrase(" "));
        pr.add(new Phrase(rb_ru.getString("fastService2"), font_ru));
        cell1 = new PdfPCell(pr);
        table1.addCell(cell1);

        pr = new Phrase("");
        if (!person.getField144().equals("")) {
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        if (!person.getField105().equals("")) {
            pr.add(new Phrase(rb_ch.getString("no"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("no"), font_ru));
        }
        cell2 = new PdfPCell(pr);
        table1.addCell(cell2);

        tcell = new PdfPCell(table1);
        tcell.setColspan(2);
        basetable.addCell(tcell);
        document.add(basetable);
        //////////////////////////////////////////////////////////page3
        basetable = new PdfPTable(2);
        basetable.setWidthPercentage(100);
        table1 = new PdfPTable(3);
        table1.setWidths(new int[] { 1, 1, 1 });
        //2.4 2.5
        pr = new Phrase(rb_ch.getString("dataSuggestion"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("dataSuggestion"), font_ru));
        cell1 = new PdfPCell(pr);
        cell2 = new PdfPCell(new Paragraph(""));
        cell1.setColspan(2);
        table1.addCell(cell1);
        table1.addCell(cell2);
        pr = new Phrase(rb_ch.getString("dataViseted"), font_ch);
        if (!person.getField106().equals("")) {
            pr.add(new Phrase("        "));
            pr.add(new Phrase(person.getField106(), font_ch));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("dataViseted"), font_ru));
        cell1 = new PdfPCell(pr);
        cell2 = new PdfPCell(new Paragraph(""));
        cell1.setColspan(2);
        table1.addCell(cell1);
        table1.addCell(cell2);
        //2.6
        pr = new Phrase(rb_ch.getString("marshrut"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("marshrut"), font_ru));
        cell1 = new PdfPCell(pr);
        table1.addCell(cell1);

        innertable = new PdfPTable(2);
        innertable.setWidthPercentage(100);
        pr = new Phrase(rb_ch.getString("date"), font_ch);
        pr.add(new Phrase(" "));
        pr.add(new Phrase(rb_ru.getString("date"), font_ru));
        innertable.addCell(pr);

        pr = new Phrase(rb_ch.getString("addressMore"), font_ch);
        pr.add(new Phrase(" "));
        pr.add(new Phrase(rb_ru.getString("addressMore"), font_ru));
        innertable.addCell(pr);

        //add 4 empty row
        /*for(int l =0 ; l < 10; l++){
            innertable.addCell(new Phrase(" "));
        }*/
        pr = new Phrase("");
        if (!person.getField107().equals("")) {
            pr.add(new Phrase(person.getField107(), font_ru));
        }
        if (!person.getField108().equals("")) {
            pr.add(new Phrase("/"));
            pr.add(new Phrase(person.getField108(), font_ru));
        }
        if (!person.getField109().equals("")) {
            pr.add(new Phrase("/"));
            pr.add(new Phrase(person.getField109(), font_ru));
        }
        innertable.addCell(pr);

        pr = new Phrase("");
        if (!person.getField110().equals("")) {
            pr.add(new Phrase(person.getField110(), font_ru));
        }
        innertable.addCell(pr);

        pr = new Phrase("");
        if (!person.getField111().equals("")) {
            pr.add(new Phrase(person.getField111(), font_ru));
        }
        if (!person.getField112().equals("")) {
            pr.add(new Phrase("/"));
            pr.add(new Phrase(person.getField112(), font_ru));
        }
        if (!person.getField113().equals("")) {
            pr.add(new Phrase("/"));
            pr.add(new Phrase(person.getField113(), font_ru));
        }
        innertable.addCell(pr);

        pr = new Phrase("");
        if (!person.getField114().equals("")) {
            pr.add(new Phrase(person.getField114(), font_ru));
        }
        innertable.addCell(pr);

        pr = new Phrase("");
        if (!person.getField115().equals("")) {
            pr.add(new Phrase(person.getField115(), font_ru));
        }
        if (!person.getField116().equals("")) {
            pr.add(new Phrase("/"));
            pr.add(new Phrase(person.getField116(), font_ru));
        }
        if (!person.getField117().equals("")) {
            pr.add(new Phrase("/"));
            pr.add(new Phrase(person.getField117(), font_ru));
        }
        innertable.addCell(pr);

        pr = new Phrase("");
        if (!person.getField118().equals("")) {
            pr.add(new Phrase(person.getField118(), font_ru));
        }
        innertable.addCell(pr);

        pr = new Phrase("");
        if (!person.getField119().equals("")) {
            pr.add(new Phrase(person.getField119(), font_ru));
        }
        if (!person.getField120().equals("")) {
            pr.add(new Phrase("/"));
            pr.add(new Phrase(person.getField120(), font_ru));
        }
        if (!person.getField121().equals("")) {
            pr.add(new Phrase("/"));
            pr.add(new Phrase(person.getField121(), font_ru));
        }
        innertable.addCell(pr);

        pr = new Phrase("");
        if (!person.getField122().equals("")) {
            pr.add(new Phrase(person.getField122(), font_ru));
        }
        innertable.addCell(pr);

        pr = new Phrase("");
        if (!person.getField123().equals("")) {
            pr.add(new Phrase(person.getField123(), font_ru));
        }
        if (!person.getField124().equals("")) {
            pr.add(new Phrase("/"));
            pr.add(new Phrase(person.getField124(), font_ru));
        }
        if (!person.getField125().equals("")) {
            pr.add(new Phrase("/"));
            pr.add(new Phrase(person.getField125(), font_ru));
        }
        innertable.addCell(pr);

        pr = new Phrase("");
        if (!person.getField126().equals("")) {
            pr.add(new Phrase(person.getField126(), font_ru));
        }
        innertable.addCell(pr);

        tcell = new PdfPCell(innertable);
        tcell.setColspan(2);
        table1.addCell(tcell);
        //2.7
        pr = new Phrase(rb_ch.getString("howpay"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("howpay"), font_ru));
        cell1 = new PdfPCell(pr);
        pr = new Phrase("");
        if (!person.getField127().equals("")) {
            pr.add(new Phrase(person.getField127(), font_ru));
        }
        cell2 = new PdfPCell(pr);
        cell1.setColspan(2);
        table1.addCell(cell1);
        table1.addCell(cell2);
        //2.8
        pr = new Phrase(rb_ch.getString("infoAboutVisit"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("infoAboutVisit"), font_ru));
        cell1 = new PdfPCell(pr);
        cell1.setRowspan(4);
        table1.addCell(cell1);

        pr = new Phrase(rb_ch.getString("nazvanie"), font_ch);
        if (!person.getField128().equals("")) {
            pr.add(new Phrase(" "));
            pr.add(new Phrase(person.getField128(), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("nazvanie"), font_ru));
        cell2 = new PdfPCell(pr);
        cell2.setColspan(2);
        table1.addCell(cell2);

        pr = new Phrase(rb_ch.getString("address"), font_ch);
        if (!person.getField129().equals("")) {
            pr.add(new Phrase(" "));
            pr.add(new Phrase(person.getField129(), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("address"), font_ru));
        cell2 = new PdfPCell(pr);
        cell2.setColspan(2);
        table1.addCell(cell2);

        pr = new Phrase(rb_ch.getString("tel"), font_ch);
        if (!person.getField130().equals("")) {
            pr.add(new Phrase(" "));
            pr.add(new Phrase(person.getField130(), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("tel"), font_ru));
        cell2 = new PdfPCell(pr);
        cell2.setColspan(2);
        table1.addCell(cell2);

        pr = new Phrase(rb_ch.getString("relation"), font_ch);
        if (!person.getField131().equals("")) {
            pr.add(new Phrase(" "));
            pr.add(new Phrase(person.getField131(), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("relation"), font_ru));
        cell2 = new PdfPCell(pr);
        cell2.setColspan(2);
        table1.addCell(cell2);
        //2.9
        pr = new Phrase(rb_ch.getString("oldVisa"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("oldVisa"), font_ru));
        cell1 = new PdfPCell(pr);
        pr = new Paragraph("");
        if (!person.getField132().equals("")) {
            pr.add(new Phrase(person.getField132(), font_ru));
        }
        cell2 = new PdfPCell(pr);
        cell1.setColspan(2);
        table1.addCell(cell1);
        table1.addCell(cell2);
        //2.10
        pr = new Phrase(rb_ch.getString("otherViseted"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("otherViseted"), font_ru));
        cell1 = new PdfPCell(pr);
        pr = new Paragraph("");
        if (!person.getField133().equals("")) {
            pr.add(new Phrase(person.getField133(), font_ru));
        }
        cell2 = new PdfPCell(pr);
        cell1.setColspan(2);
        table1.addCell(cell1);
        table1.addCell(cell2);
        //
        tcell = new PdfPCell(table1);
        tcell.setColspan(2);
        basetable.addCell(tcell);
        /////////////////////////////////////
        document.add(basetable);

        ///////////////////////////////////////part3
        pr = new Phrase("\n");
        pr.add(new Phrase(rb_ch.getString("part3"), font_ch));
        pr.add(new Phrase(" "));
        pr.add(new Phrase(rb_ru.getString("part3"), font_ru));
        pr.add(new Phrase("\n"));
        document.add(pr);
        //3.1
        basetable = new PdfPTable(2);
        basetable.setWidthPercentage(100);
        table1 = new PdfPTable(4);
        table1.setWidths(new int[] { 1, 1, 1, 1 });

        pr = new Phrase(rb_ch.getString("wrongVisit"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("wrongVisit"), font_ru));
        cell1 = new PdfPCell(pr);
        cell1.setColspan(3);
        table1.addCell(cell1);

        pr = new Phrase("");
        if (!person.getField134().equals("")) {
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        if (!person.getField135().equals("")) {
            pr.add(new Phrase(rb_ch.getString("no"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("no"), font_ru));
        }

        cell2 = new PdfPCell(pr);
        table1.addCell(cell2);
        //3.2
        pr = new Phrase(rb_ch.getString("rejectedVisit"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("rejectedVisit"), font_ru));
        cell1 = new PdfPCell(pr);
        cell1.setColspan(3);
        table1.addCell(cell1);

        pr = new Phrase("");
        if (!person.getField136().equals("")) {
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        if (!person.getField137().equals("")) {
            pr.add(new Phrase(rb_ch.getString("no"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("no"), font_ru));
        }
        cell2 = new PdfPCell(pr);
        table1.addCell(cell2);
        //3.3
        pr = new Phrase(rb_ch.getString("sudimost"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("sudimost"), font_ru));
        cell1 = new PdfPCell(pr);
        cell1.setColspan(3);
        table1.addCell(cell1);

        pr = new Phrase("");
        if (!person.getField138().equals("")) {
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        if (!person.getField139().equals("")) {
            pr.add(new Phrase(rb_ch.getString("no"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("no"), font_ru));
        }
        cell2 = new PdfPCell(pr);
        table1.addCell(cell2);

        //3.4
        pr = new Phrase(rb_ch.getString("illness"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("illness"), font_ru));
        cell1 = new PdfPCell(pr);
        cell1.setColspan(3);
        table1.addCell(cell1);

        pr = new Phrase("");
        if (!person.getField140().equals("")) {
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        if (!person.getField141().equals("")) {
            pr.add(new Phrase(rb_ch.getString("no"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("no"), font_ru));
        }
        cell2 = new PdfPCell(pr);
        table1.addCell(cell2);

        //3.5
        pr = new Phrase(rb_ch.getString("ilnessContry"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("ilnessContry"), font_ru));
        cell1 = new PdfPCell(pr);
        cell1.setColspan(3);
        table1.addCell(cell1);

        pr = new Phrase("");
        if (!person.getField142().equals("")) {
            pr.add(new Phrase(rb_ch.getString("yes"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("yes"), font_ru));
        }
        if (!person.getField143().equals("")) {
            pr.add(new Phrase(rb_ch.getString("no"), font_ch));
            pr.add(new Phrase("  "));
            pr.add(new Phrase(rb_ru.getString("no"), font_ru));
        }
        cell2 = new PdfPCell(pr);
        table1.addCell(cell2);
        //3.6
        pr = new Phrase(rb_ch.getString("ilnessContryMoreDesc"), font_ch);
        if (!person.getField145().equals("")) {
            pr.add(new Phrase(person.getField145(), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("ilnessContryMoreDesc"), font_ru));

        cell1 = new PdfPCell(pr);
        cell1.setColspan(4);
        table1.addCell(cell1);
        //3.7
        pr = new Phrase(rb_ch.getString("ilnessContryOtherDesc"), font_ch);
        if (!person.getField146().equals("")) {
            pr.add(new Phrase(person.getField146(), font_ru));
        }
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("ilnessContryOtherDesc"), font_ru));
        cell1 = new PdfPCell(pr);
        cell1.setColspan(4);
        table1.addCell(cell1);
        //3.8
        pr = new Phrase(rb_ch.getString("ilnessContryPersonData"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("ilnessContryPersonData"), font_ru));
        cell1 = new PdfPCell(pr);
        cell1.setColspan(4);
        table1.addCell(cell1);
        //3.8.1
        pr = new Phrase(rb_ch.getString("info"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("info"), font_ru));
        pr.add(new Phrase("\n"));
        cell1 = new PdfPCell(pr);
        table1.addCell(cell1);
        //3.8.2
        pr = new Phrase(rb_ch.getString("person1"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("person1"), font_ru));
        pr.add(new Phrase("\n"));
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ch.getString("photo"), font_ch));
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("photo"), font_ru));
        cell1 = new PdfPCell(pr);
        table1.addCell(cell1);
        //3.8.3
        pr = new Phrase(rb_ch.getString("person2"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("person2"), font_ru));
        pr.add(new Phrase("\n"));
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ch.getString("photo"), font_ch));
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("photo"), font_ru));
        cell1 = new PdfPCell(pr);
        table1.addCell(cell1);
        //3.8.4
        pr = new Phrase(rb_ch.getString("person3"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("person3"), font_ru));
        pr.add(new Phrase("\n"));
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ch.getString("photo"), font_ch));
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("photo"), font_ru));
        cell1 = new PdfPCell(pr);
        table1.addCell(cell1);
        //3.8.body
        //for(int i = 1; i< 4; i++){
        //fio
        pr = new Phrase(rb_ch.getString("part3.8_1"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("part3.8_1"), font_ru));
        cell1 = new PdfPCell(pr);
        table1.addCell(cell1);

        pr = new Phrase();
        if (!person.getField147().equals("")) {
            pr.add(new Phrase(person.getField147(), font_ru));
        }
        cell1 = new PdfPCell(pr);
        table1.addCell(cell1);

        pr = new Phrase();
        if (!person.getField148().equals("")) {
            pr.add(new Phrase(person.getField148(), font_ru));
        }
        cell1 = new PdfPCell(pr);
        table1.addCell(cell1);

        pr = new Phrase();
        if (!person.getField149().equals("")) {
            pr.add(new Phrase(person.getField149(), font_ru));
        }
        cell1 = new PdfPCell(pr);
        table1.addCell(cell1);
        //sex
        pr = new Phrase(rb_ch.getString("part3.8_2"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("part3.8_2"), font_ru));
        cell1 = new PdfPCell(pr);
        table1.addCell(cell1);

        pr = new Phrase();
        if (!person.getField150().equals("")) {
            pr.add(new Phrase(person.getField150(), font_ru));
        }
        cell1 = new PdfPCell(pr);
        table1.addCell(cell1);

        pr = new Phrase();
        if (!person.getField151().equals("")) {
            pr.add(new Phrase(person.getField151(), font_ru));
        }
        cell1 = new PdfPCell(pr);
        table1.addCell(cell1);

        pr = new Phrase();
        if (!person.getField152().equals("")) {
            pr.add(new Phrase(person.getField152(), font_ru));
        }
        cell1 = new PdfPCell(pr);
        table1.addCell(cell1);
        //
        pr = new Phrase(rb_ch.getString("part3.8_3"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("part3.8_3"), font_ru));
        cell1 = new PdfPCell(pr);
        table1.addCell(cell1);
        pr = new Phrase("");
        if (!person.getField153().equals("")) {
            pr.add(new Phrase(person.getField153(), font_ru));
        }
        if (!person.getField154().equals("")) {
            pr.add(new Phrase("/"));
            pr.add(new Phrase(person.getField154(), font_ru));
        }
        if (!person.getField155().equals("")) {
            pr.add(new Phrase("/"));
            pr.add(new Phrase(person.getField155(), font_ru));
        }
        cell1 = new PdfPCell(pr);
        table1.addCell(cell1);

        pr = new Phrase("");
        if (!person.getField156().equals("")) {
            pr.add(new Phrase(person.getField156(), font_ru));
        }
        if (!person.getField157().equals("")) {
            pr.add(new Phrase("/"));
            pr.add(new Phrase(person.getField157(), font_ru));
        }
        if (!person.getField158().equals("")) {
            pr.add(new Phrase("/"));
            pr.add(new Phrase(person.getField158(), font_ru));
        }
        cell1 = new PdfPCell(pr);
        table1.addCell(cell1);

        pr = new Phrase("");
        if (!person.getField159().equals("")) {
            pr.add(new Phrase(person.getField159(), font_ru));
        }
        if (!person.getField160().equals("")) {
            pr.add(new Phrase("/"));
            pr.add(new Phrase(person.getField160(), font_ru));
        }
        if (!person.getField161().equals("")) {
            pr.add(new Phrase("/"));
            pr.add(new Phrase(person.getField161(), font_ru));
        }
        cell1 = new PdfPCell(pr);
        table1.addCell(cell1);
        //}
        tcell = new PdfPCell(table1);
        tcell.setColspan(2);
        basetable.addCell(tcell);
        document.add(basetable);
        //////////////////////////////////////part4
        pr = new Phrase("\n");
        pr.add(new Phrase(rb_ch.getString("part4"), font_ch));
        pr.add(new Phrase(" "));
        pr.add(new Phrase(rb_ru.getString("part4"), font_ru));
        pr.add(new Phrase("\n"));
        document.add(pr);
        //4.1
        basetable = new PdfPTable(2);
        basetable.setWidthPercentage(100);
        table1 = new PdfPTable(2);
        table1.setWidths(new int[] { 1, 1 });

        pr = new Phrase(rb_ch.getString("part4.1"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("part4.1"), font_ru));
        cell1 = new PdfPCell(pr);
        cell1.setColspan(2);
        table1.addCell(cell1);

        //4.2
        pr = new Phrase(rb_ch.getString("part4.2"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("part4.2"), font_ru));
        cell1 = new PdfPCell(pr);
        cell1.setColspan(2);
        table1.addCell(cell1);

        //4.3
        pr = new Phrase(rb_ch.getString("part4.3"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("part4.3"), font_ru));
        cell1 = new PdfPCell(pr);
        cell1.setColspan(2);
        table1.addCell(cell1);
        //4.4
        pr = new Phrase(rb_ch.getString("part4.4"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("part4.4"), font_ru));
        cell1 = new PdfPCell(pr);
        table1.addCell(cell1);
        pr = new Phrase(rb_ch.getString("part4.5"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("part4.5"), font_ru));
        cell1 = new PdfPCell(pr);
        table1.addCell(cell1);
        //4.5
        pr = new Phrase(rb_ch.getString("part4.5"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("part4.5"), font_ru));
        cell1 = new PdfPCell(pr);
        cell1.setColspan(2);
        table1.addCell(cell1);
        //
        tcell = new PdfPCell(table1);
        tcell.setColspan(2);
        basetable.addCell(tcell);
        //
        document.add(basetable);
        //////////////////////////////////////part5
        pr = new Phrase("\n");
        pr.add(new Phrase(rb_ch.getString("part5"), font_ch));
        pr.add(new Phrase(" "));
        pr.add(new Phrase(rb_ru.getString("part5"), font_ru));
        pr.add(new Phrase("\n"));
        document.add(pr);

        basetable = new PdfPTable(2);
        basetable.setWidthPercentage(100);
        table1 = new PdfPTable(4);
        table1.setWidths(new int[] { 1, 1, 1, 1 });
        //5.1 5.2
        pr = new Phrase(rb_ch.getString("part5.1"), font_ch);
        pr.add(new Phrase(" "));
        pr.add(new Phrase(rb_ru.getString("part5.1"), font_ru));
        cell1 = new PdfPCell(pr);
        table1.addCell(cell1);

        pr = new Phrase();
        if (!person.getField162().equals("")) {
            pr.add(new Phrase("                "));
            pr.add(new Phrase(person.getField162(), font_ru));
        }
        cell1 = new PdfPCell(pr);
        table1.addCell(cell1);

        pr = new Phrase(rb_ch.getString("part5.2"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("part5.2"), font_ru));
        cell1 = new PdfPCell(pr);
        table1.addCell(cell1);

        pr = new Phrase();
        if (!person.getField163().equals("")) {
            pr.add(new Phrase("                "));
            pr.add(new Phrase(person.getField163(), font_ru));
        }
        cell1 = new PdfPCell(pr);
        table1.addCell(cell1);
        //5.3 5.4
        pr = new Phrase(rb_ch.getString("part5.3"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("part5.3"), font_ru));
        cell1 = new PdfPCell(pr);
        table1.addCell(cell1);

        pr = new Phrase();
        if (!person.getField164().equals("")) {
            pr.add(new Phrase("                "));
            pr.add(new Phrase(person.getField164(), font_ru));
        }
        cell1 = new PdfPCell(pr);
        table1.addCell(cell1);

        pr = new Phrase(rb_ch.getString("part5.4"), font_ch);
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ru.getString("part5.4"), font_ru));
        cell1 = new PdfPCell(pr);
        table1.addCell(cell1);

        pr = new Phrase();
        if (!person.getField165().equals("")) {
            pr.add(new Phrase("                "));
            pr.add(new Phrase(person.getField165(), font_ru));
        }
        cell1 = new PdfPCell(pr);
        table1.addCell(cell1);
        //5.5
        pr = new Phrase(rb_ch.getString("part5.5"), font_ch);
        pr.add(new Phrase(" "));
        pr.add(new Phrase(rb_ru.getString("part5.5"), font_ru));
        pr.add(new Phrase("\n"));
        pr.add(new Phrase(rb_ch.getString("part5.5.1"), font_ch));
        pr.add(new Phrase(" "));
        pr.add(new Phrase(rb_ru.getString("part5.5.1"), font_ru));
        cell1 = new PdfPCell(pr);
        cell1.setColspan(4);
        table1.addCell(cell1);
        //5.5
        pr = new Phrase(rb_ch.getString("part5.6"), font_ch);
        pr.add(new Phrase(" "));
        pr.add(new Phrase(rb_ru.getString("part5.6"), font_ru));
        cell1 = new PdfPCell(pr);
        cell1.setColspan(2);
        table1.addCell(cell1);

        pr = new Phrase(rb_ch.getString("part5.7"), font_ch);
        pr.add(new Phrase(" "));
        pr.add(new Phrase(rb_ru.getString("part5.7"), font_ru));
        cell1 = new PdfPCell(pr);
        cell1.setColspan(2);
        table1.addCell(cell1);
        //
        tcell = new PdfPCell(table1);
        tcell.setColspan(2);
        basetable.addCell(tcell);
        /////////////////////////////////////
        document.add(basetable);
    } catch (Exception e) {
        System.err.println(e.getClass().getName() + ": " + e.getMessage());
        System.exit(0);
    }

    // step 5
    document.close();
    //
}

From source file:mhp_ph.PHprint.java

License:Open Source License

/**
 * Print articles as pdf//w  w  w .  j  a v a 2  s.  c o  m
 * @param ll Articles
 * @param f Format
 * @param n Filename
 */
public static void printPdf(LinkedList<phArt> ll, format f, String n) {
    Document doc = new Document(PageSize.A4, 50, 50, 50, 50);
    try {
        PdfWriter pdf = PdfWriter.getInstance(doc, new FileOutputStream(n));
        doc.addSubject("Przegld Historyczny");
        doc.open();
        BaseFont rr = BaseFont.createFont("FreeSerif.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
        BaseFont ii = BaseFont.createFont("FreeSerifItalic.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
        Font r = new Font(rr);
        Font i = new Font(ii);
        for (phArt a : ll) {
            Phrase p = new Phrase();
            for (articleEntry e : formatArticle(a, f)) {
                switch (e.getStyle()) {
                case normal: {
                    p.add(new Chunk(e.getString(), r));
                    break;
                }
                case italic: {
                    p.add(new Chunk(e.getString(), i));
                    break;
                }
                }
            }
            doc.add(new Paragraph(p));
            doc.add(new Paragraph("\n"));
        }
        doc.add(new Paragraph(" \n"));
    } catch (Exception e) {
    }
    doc.close();
}

From source file:mkl.testarea.itext5.pdfcleanup.StrictPdfCleanUpProcessor.java

License:Open Source License

private void drawOverlayText(PdfContentByte canvas, List<Rectangle> textRectangles, PdfString overlayText,
        PdfString otDA, PdfNumber otQ, PdfBoolean otRepeat) throws DocumentException, IOException {
    ColumnText ct = new ColumnText(canvas);
    ct.setLeading(0, 1.2F);//ww  w .  j  a  v  a2s  .c  o m
    ct.setUseAscender(true);

    String otStr = overlayText.toUnicodeString();

    canvas.saveState();
    Map<String, List> parsedDA = parseDAParam(otDA);

    Font font = null;

    if (parsedDA.containsKey(STROKE_COLOR)) {
        List strokeColorArgs = parsedDA.get(STROKE_COLOR);
        setStrokeColor(canvas, strokeColorArgs);
    }

    if (parsedDA.containsKey(FILL_COLOR)) {
        List fillColorArgs = parsedDA.get(FILL_COLOR);
        setFillColor(canvas, fillColorArgs);
    }

    if (parsedDA.containsKey("Tf")) {
        List tfArgs = parsedDA.get("Tf");
        font = retrieveFontFromAcroForm((PdfName) tfArgs.get(0), (PdfNumber) tfArgs.get(1));
    }

    for (Rectangle textRect : textRectangles) {
        ct.setSimpleColumn(textRect);

        if (otQ != null) {
            ct.setAlignment(otQ.intValue());
        }

        Phrase otPhrase;

        if (font != null) {
            otPhrase = new Phrase(otStr, font);
        } else {
            otPhrase = new Phrase(otStr);
        }

        float y = ct.getYLine();

        if (otRepeat != null && otRepeat.booleanValue()) {
            int status = ct.go(true);

            while (!ColumnText.hasMoreText(status)) {
                otPhrase.add(otStr);
                ct.setText(otPhrase);
                ct.setYLine(y);
                status = ct.go(true);
            }
        }

        ct.setText(otPhrase);
        ct.setYLine(y);
        ct.go();
    }

    canvas.restoreState();
}

From source file:org.larz.dom4.editor.ReportGenerator.java

License:Open Source License

private static PdfPTable getTable(String[] columns, String[] columnNames, ValueTranslator[] trans,
        ValueCombiner[] combine, List<Map.Entry<String, ModObject>> list) {
    PdfPTable table = new PdfPTable(columns.length);
    table.setWidthPercentage(100f);/*  w  ww.  j  a  va2  s  .c  om*/
    table.setHorizontalAlignment(Element.ALIGN_LEFT);
    for (String col : columnNames) {
        PdfPCell c = new PdfPCell(new Phrase(col, SUBTITLE));
        c.setBackgroundColor(BaseColor.LIGHT_GRAY);
        table.addCell(c);
    }
    table.setHeaderRows(1);

    for (Map.Entry<String, ModObject> innerEntry : list) {
        String name = innerEntry.getValue().title;
        Map<String, PropertyValues> map = innerEntry.getValue().propertyMap;

        List<Map.Entry<String, PropertyValues>> list2 = new ArrayList<Map.Entry<String, PropertyValues>>();
        for (Map.Entry<String, PropertyValues> innerEntry2 : map.entrySet()) {
            list2.add(innerEntry2);
        }
        Collections.sort(list2, new Comparator<Map.Entry<String, PropertyValues>>() {
            @Override
            public int compare(Map.Entry<String, PropertyValues> o1, Map.Entry<String, PropertyValues> o2) {
                return o1.getKey().compareTo(o2.getKey());
            }
        });

        if (list2.size() == 0)
            continue;

        PdfPCell[] cells = new PdfPCell[columns.length];
        cells[0] = new PdfPCell();
        cells[0].addElement(new Phrase(name, BOLD_TEXT));

        for (int i = 1; i < cells.length; i++) {
            cells[i] = new PdfPCell();
            if (combine != null && combine[i] != null) {
                String[] neededCols = combine[i].getNeededColumns();
                String[] oldValues = new String[neededCols.length];
                String[] newValues = new String[neededCols.length];
                for (int j = 0; j < neededCols.length; j++) {
                    for (Map.Entry<String, PropertyValues> entry : list2) {
                        if (entry.getKey().equals(neededCols[j])) {
                            oldValues[j] = entry.getValue().oldValue;
                            newValues[j] = entry.getValue().newValue;
                            break;
                        }
                    }
                }
                // Put old values into null new values
                boolean hasNew = false;
                for (int k = 0; k < newValues.length; k++) {
                    if (newValues[k] != null) {
                        hasNew = true;
                        break;
                    }
                }
                if (hasNew) {
                    for (int k = 0; k < newValues.length; k++) {
                        if (newValues[k] == null) {
                            newValues[k] = oldValues[k];
                        }
                    }
                }
                String newValue = combine[i].translate(newValues);
                String oldValue = combine[i].translate(oldValues);
                if (newValue != null) {
                    Phrase phrase = new Phrase();
                    phrase.add(new Chunk(newValue, BOLD_TEXT));
                    if (oldValue != null) {
                        phrase.add(new Chunk(" (" + oldValue + ")", TEXT));
                    }
                    cells[i].addElement(phrase);
                } else if (oldValue != null) {
                    cells[i].addElement(new Phrase(oldValue, TEXT));
                }
            } else {
                for (Map.Entry<String, PropertyValues> entry : list2) {
                    if (entry.getKey().equals(columns[i])) {
                        String oldValue = entry.getValue().oldValue;
                        String newValue = entry.getValue().newValue;
                        if (trans != null && trans.length > i && trans[i] != null) {
                            oldValue = trans[i].translate(oldValue);
                            newValue = trans[i].translate(newValue);
                        }
                        if (newValue != null) {
                            Phrase phrase = new Phrase();
                            phrase.add(new Chunk(newValue, BOLD_TEXT));
                            if (oldValue != null && !oldValue.equals("null")) {
                                phrase.add(new Chunk(" (" + oldValue + ")", TEXT));
                            }
                            cells[i].addElement(phrase);
                        } else if (oldValue != null && !oldValue.equals("null")) {
                            cells[i].addElement(new Phrase(oldValue, TEXT));
                        }
                        break;
                    }
                }
            }
        }

        for (PdfPCell cell : cells) {
            table.addCell(cell);
        }
    }
    return table;
}

From source file:PDF.CrearPDF_Ficha.java

public void generarPDF(ServletOutputStream sops, DatosPDF datos, String url) {

    try {//from w w w .jav  a  2s  .  com

        Document documento = new Document();
        //            ByteArrayOutputStream baos = new ByteArrayOutputStream();
        PdfWriter writer = PdfWriter.getInstance(documento, sops);
        documento.open();

        Image itt_logo;
        try {
            itt_logo = Image.getInstance(url);
            Image Logo_itt = Image.getInstance(itt_logo);
            Logo_itt.setAbsolutePosition(50f, 698f);
            Logo_itt.scaleAbsolute(90, 100);
            documento.add(Logo_itt);
        } catch (BadElementException | IOException ex) {
            Logger.getLogger(CrearPDF_Ficha.class.getName()).log(Level.SEVERE, null, ex);
        }

        PdfContentByte rectangulo_info = writer.getDirectContentUnder();
        drawRectangle(rectangulo_info, 430, 648, 90, 100);
        Paragraph leyendaFoto = new Paragraph("\nFOTO:\n", FontFactory.getFont("arial", 14, Font.BOLD));
        leyendaFoto.setIndentationLeft(200f);
        Paragraph titulo = new Paragraph("INSTITUTO TECNOLGICO DE TOLUCA", FontFactory.getFont("arial", 14));
        titulo.setAlignment(Element.ALIGN_CENTER);

        Paragraph asunto = new Paragraph("FICHA DE EXAMEN", FontFactory.getFont("arial", 12));
        asunto.setAlignment(Element.ALIGN_CENTER);

        Chunk folio1 = new Chunk("FICHA PARA EL EXAMEN DE ADMISIN: ", FontFactory.getFont("arial", 10));
        Chunk folio2 = new Chunk(datos.getFicha(), FontFactory.getFont("arial", 10, Font.BOLD));

        Phrase fol = new Phrase();
        fol.add(folio1);
        fol.add(folio2);

        Paragraph noFicha = new Paragraph(fol);
        noFicha.setAlignment(Element.ALIGN_LEFT);

        Chunk nombre1 = new Chunk("NOMBRE DEL SOLICITANTE: ", FontFactory.getFont("arial", 10));
        Chunk nombre2 = new Chunk(datos.getNombre(), FontFactory.getFont("arial", 10, Font.BOLD));

        Phrase nom = new Phrase();
        nom.add(nombre1);
        nom.add(nombre2);

        Paragraph nombre = new Paragraph(nom);
        nombre.setAlignment(Element.ALIGN_LEFT);

        Chunk in1 = new Chunk("PROCESO PARA EL REGISTRO DE ASPIRANTES EN EL PERIODO: ",
                FontFactory.getFont("arial", 10));
        Chunk in2 = new Chunk(datos.getPeriodoConcursa().toUpperCase(),
                FontFactory.getFont("arial", 10, Font.BOLD));

        Phrase in = new Phrase();
        in.add(in1);
        in.add(in2);

        Paragraph instrucciones = new Paragraph(in);
        instrucciones.setAlignment(Element.ALIGN_LEFT);

        Chunk folCen1 = new Chunk("1.- NMERO DE FOLIO CENEVAL: ", FontFactory.getFont("arial", 10));
        Chunk folCen2 = new Chunk(datos.getFolioCENEVAL(), FontFactory.getFont("arial", 10, Font.BOLD));

        Phrase folC = new Phrase();
        folC.add(folCen1);
        folC.add(folCen2);

        Paragraph folioCENEVAL = new Paragraph(folC);
        folioCENEVAL.setAlignment(Element.ALIGN_LEFT);

        Chunk fechas1 = new Chunk("2.- LOS EX?MENES DE ADMISIN SE APLICAR?N LOS D?AS: ",
                FontFactory.getFont("arial", 10));
        Chunk fechas2 = new Chunk(datos.getFechaExamenCeneval() + " (" + datos.getLugarExamenCeneval() + ")",
                FontFactory.getFont("arial", 10, Font.BOLD));
        Chunk fechas3 = new Chunk(" Y ", FontFactory.getFont("arial", 10));
        Chunk fechas4 = new Chunk(datos.getFechaExamenMate() + " (" + datos.getLugarExamenMate() + ")",
                FontFactory.getFont("arial", 10, Font.BOLD));

        Phrase fechas = new Phrase();
        fechas.add(fechas1);
        fechas.add(fechas2);
        fechas.add(fechas3);
        fechas.add(fechas4);

        Paragraph fechaExamenes = new Paragraph(fechas);
        fechaExamenes.setAlignment(Element.ALIGN_LEFT);

        Phrase lugar = new Phrase();

        Paragraph lugarYhora = new Paragraph(lugar);
        lugarYhora.setAlignment(Element.ALIGN_LEFT);

        Chunk paginaPub1 = new Chunk(
                "3.- LA PUBLICACIN DE LOS RESULTADOS SER? NICAMENTE EN LA P?GINA WEB: ",
                FontFactory.getFont("arial", 10));

        Anchor url_itt = new Anchor(datos.getPagResultados());
        url_itt.setReference(datos.getPagResultados());

        Phrase pag = new Phrase();
        pag.add(paginaPub1);
        pag.add(url_itt);

        Paragraph pagWeb = new Paragraph(pag);

        Chunk diaPub1 = new Chunk("EL D?A: ", FontFactory.getFont("arial", 10));
        Chunk diaPub2 = new Chunk(convertir(datos.getDiaPublicacion() + "-"),
                FontFactory.getFont("arial", 10, Font.BOLD));

        Phrase dia = new Phrase();
        dia.add(diaPub1);
        dia.add(diaPub2);

        Paragraph diaResultados = new Paragraph(dia);
        diaResultados.setAlignment(Element.ALIGN_LEFT);

        Chunk notas = new Chunk("\nNOTAS:\n", FontFactory.getFont("arial", 14, Font.BOLD));

        Chunk uno = new Chunk("1.- ", FontFactory.getFont("arial", 10, Font.BOLD));

        Chunk guias = new Chunk("Guas de estudio:\n   - (CENEVAL) \n", FontFactory.getFont("arial", 10));

        Anchor url_guia_cen = new Anchor("     " + datos.getEstudioCeneval());
        // url_guia_cen.setReference(datos.getEstudioCeneval());

        Chunk ceneval_inter = new Chunk("\n   - (CENEVAL INTERACTIVA) \n", FontFactory.getFont("arial", 10));

        Anchor url_guia_cen_inter = new Anchor("     " + datos.getEstudioCenevalInt());
        url_guia_cen_inter.setReference(datos.getEstudioCenevalInt());

        Chunk tem_mate_itt = new Chunk("\n   - Temario de Matemticas (TECNOLGICO DE TOLUCA)\n\n",
                FontFactory.getFont("arial", 10));
        Chunk dos = new Chunk("2.- ", FontFactory.getFont("arial", 10, Font.BOLD));
        Chunk veri = new Chunk("Verifique que el nmero de folio de Ceneval de esta ficha, coincida con el",
                FontFactory.getFont("arial", 10));
        Chunk fol_ceneval = new Chunk(" FOLIO CENEVAL ", FontFactory.getFont("arial", 10, Font.BOLD));
        Chunk capturado = new Chunk("capturado en la informacin proporcionada por el Tecnlogico.\n\n",
                FontFactory.getFont("arial", 10));
        Chunk tres = new Chunk("3.- ", FontFactory.getFont("arial", 10, Font.BOLD));
        Chunk dia_exam = new Chunk(
                "El da del examen deber presentarse con el presente documento, pase de ingreso al examen(Ceneval), una identificacin con fotografa reciente(credencial escolar, IMSS, ISSSTE, ISSEMYM, licencia, pasaporte), lpiz del nmero 2 y goma.\n\n",
                FontFactory.getFont("arial", 10));
        Chunk cuatro = new Chunk("4.- ", FontFactory.getFont("arial", 10, Font.BOLD));
        Chunk curso = new Chunk(
                "Si curs sus estudios de secundaria o bachillerato en el extranjero deber presentar revalidacin de estudios correspondientes al momento de la inscripcin.\n",
                FontFactory.getFont("arial", 10));
        Chunk cinco = new Chunk("\n5.- ", FontFactory.getFont("arial", 10, Font.BOLD));
        Chunk examenes = new Chunk(
                "Los exmenes que se evaluarn son:       1) ADMISIN Y DIAGNSTICO.     2) MATEM?TICAS.",
                FontFactory.getFont("arial", 10));

        Phrase ulti = new Phrase();
        ulti.add(notas);
        ulti.add(uno);
        ulti.add(guias);
        ulti.add(url_guia_cen);
        ulti.add(ceneval_inter);
        ulti.add(url_guia_cen_inter);
        ulti.add(tem_mate_itt);
        ulti.add(dos);
        ulti.add(veri);
        ulti.add(fol_ceneval);
        ulti.add(capturado);
        ulti.add(tres);
        ulti.add(dia_exam);
        ulti.add(cuatro);
        ulti.add(curso);
        ulti.add(cinco);
        ulti.add(examenes);

        Paragraph ultimo = new Paragraph(ulti);
        ultimo.setAlignment(Element.ALIGN_LEFT);

        documento.addTitle("Ficha de Examen");
        documento.addSubject("Instituto Tecnolgico de Toluca");
        documento.addKeywords("Instituto Tecnolgico de Toluca");
        documento.addAuthor("Departamento de Servicios escolares");
        documento.addCreator("Departamento de Servicios escolares");
        documento.add(titulo);
        documento.add(asunto);
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));

        documento.add(noFicha);
        documento.add(nombre);
        documento.add(new Paragraph(" "));
        documento.add(instrucciones);
        documento.add(new Paragraph(" "));
        documento.add(folioCENEVAL);
        documento.add(fechaExamenes);
        documento.add(lugarYhora);
        documento.add(pagWeb);
        documento.add(diaResultados);
        documento.add(new Paragraph(" "));
        documento.add(ultimo);

        documento.close();
    } catch (DocumentException ex) {
        Logger.getLogger(CrearPDF_Ficha.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:quanlyhoadon.PDFProcess.java

public boolean printPDF(String dest, Company company, Bill bill, LinhTinh lt) {
    try {//  w  ww .j ava  2  s .  c om
        BaseFont urName = BaseFont.createFont("font/Time_New_Roman.TTF", BaseFont.IDENTITY_H,
                BaseFont.EMBEDDED);
        Font nameFont = new Font(urName, 16, Font.BOLD);
        Font addFont = new Font(urName, 12);
        Font boldFont = new Font(urName, 14, Font.BOLD);
        Font contentFont = new Font(urName, 14);
        Font footFont = new Font(urName, 16);

        Document document = new Document(PageSize.A4.rotate());
        PdfWriter.getInstance(document, new FileOutputStream(dest));
        document.open();

        PdfPTable table = new PdfPTable(3);
        table.setWidthPercentage(100);
        table.setWidths(new float[] { 2, 6, 3 });

        //logo
        Image img = Image.getInstance("logo.jpg");
        img.scaleAbsolute(100, 100);
        PdfPCell cell = new PdfPCell(img);
        cell.setBorder(PdfPCell.NO_BORDER);

        //middle content
        String name = company.getName();
        String address = "\n\n?C: " + company.getAddress();
        String phone = "\n\n?T: " + company.getPhone();
        String hed = "\n\n     PHIU B?O GI?";

        Phrase mid = new Phrase();
        mid.add(new Chunk(name, nameFont));
        mid.add(new Chunk(address + phone, addFont));
        mid.add(new Chunk(hed, nameFont));

        PdfPCell midCell = new PdfPCell(mid);
        //      midCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        midCell.setPaddingTop(15);
        midCell.setPaddingLeft(40);
        midCell.setPaddingRight(15);
        midCell.setPaddingBottom(15);
        midCell.setBorder(PdfPCell.NO_BORDER);

        // right content
        String soCt = "S CT: " + bill.getId();
        String date = "\n\nNgy: " + bill.getDate() + "\n\nKho : " + lt.getKho();

        Phrase right = new Phrase();
        right.add(new Chunk(soCt + date, addFont));
        PdfPCell rightCell = new PdfPCell(right);
        rightCell.setPadding(15);
        rightCell.setBorder(PdfPCell.NO_BORDER);

        table.addCell(cell);
        table.addCell(midCell);
        table.addCell(rightCell);

        document.add(table);

        Phrase p1 = new Phrase();
        p1.add(new Chunk("?n v: ", addFont));
        p1.add(new Chunk(lt.getDonVi(), boldFont));
        p1.add(new Chunk("\n?a Ch: \n", addFont));

        Paragraph pagra = new Paragraph(p1);
        pagra.setIndentationLeft(15);
        pagra.setSpacingBefore(10);
        pagra.setSpacingAfter(10);
        document.add(pagra);

        //table lt
        PdfPTable tablList = new PdfPTable(6);

        tablList.setWidthPercentage(100);
        tablList.setWidths(new float[] { 1, 5, 7, 2, 3, 4 });

        String title[] = { "STT", "M Hng", "Tn Hng", "SL", "?n Gi", "Thnh Ti?n" };
        for (int i = 0; i < title.length; ++i) {
            Phrase phr = new Phrase();
            phr.add(new Chunk(title[i], boldFont));
            PdfPCell p = new PdfPCell(phr);
            p.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            tablList.addCell(p);
        }
        //--- add content
        for (int i = 0; i < bill.getCount(); ++i) {
            Phrase[] phrase = new Phrase[6];
            PdfPCell[] pCell = new PdfPCell[6];

            for (int k = 0; k < 6; ++k) {
                phrase[k] = new Phrase();
            }
            phrase[0].add(new Chunk((i + 1) + "", contentFont));
            phrase[1].add(new Chunk(bill.getMaHangAt(i), contentFont));
            phrase[2].add(new Chunk(bill.getTenHangAt(i), contentFont));
            phrase[3].add(new Chunk(bill.getSoLuongAt(i) + "", contentFont));
            phrase[4].add(new Chunk(bill.getDonGiaAt(i) + "", contentFont));
            phrase[5].add(new Chunk(bill.getThanhTienAt(i) + "", contentFont));

            for (int j = 0; j < 6; ++j) {
                pCell[j] = new PdfPCell(phrase[j]);
                pCell[j].setHorizontalAlignment(PdfPCell.ALIGN_CENTER);

                tablList.addCell(pCell[j]);
            }
        }

        PdfPCell cell1 = new PdfPCell(new Phrase(new Chunk("Tng", boldFont)));
        cell1.setColspan(3);
        cell1.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        tablList.addCell(cell1);

        //
        PdfPCell cell2 = new PdfPCell(new Phrase(new Chunk("" + bill.getTong(), boldFont)));
        cell2.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        tablList.addCell(cell2);

        //
        PdfPCell cell3 = new PdfPCell(new Phrase(new Chunk("", boldFont)));
        cell3.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        tablList.addCell(cell3);

        //
        PdfPCell cell4 = new PdfPCell(new Phrase(new Chunk(String.format("%,d", bill.tongTien()), boldFont)));
        cell4.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        tablList.addCell(cell4);

        document.add(tablList);
        //-------------------in phuong thuc thanh toan
        Phrase p2 = new Phrase();
        p2.add(new Chunk("Phng thc thanh ton: ", contentFont));
        p2.add(new Chunk(lt.getThanhToan(), boldFont));
        p2.add(new Chunk("\nLu  mua hng min tr li. Vui lng gi phiu trong 7 ngy: ",
                contentFont));

        Paragraph pagra2 = new Paragraph(p2);
        pagra2.setSpacingBefore(5);
        pagra2.setSpacingAfter(5);
        document.add(pagra2);

        //---- footer content
        PdfPTable tblFoot = new PdfPTable(3);

        tblFoot.setWidthPercentage(100);
        tblFoot.setWidths(new float[] { 1, 1, 1 });

        PdfPCell leftFootCell = new PdfPCell(new Phrase(new Chunk("NGI LP ", footFont)));
        PdfPCell midFootCell = new PdfPCell(new Phrase(new Chunk("K TO?N ", footFont)));
        PdfPCell rightFootCell = new PdfPCell(new Phrase(new Chunk("TH TRNG ?N V ", footFont)));

        leftFootCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        leftFootCell.setBorder(PdfPCell.NO_BORDER);
        midFootCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        midFootCell.setBorder(PdfPCell.NO_BORDER);
        rightFootCell.setBorder(PdfPCell.NO_BORDER);
        rightFootCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);

        tblFoot.addCell(leftFootCell);
        tblFoot.addCell(midFootCell);
        tblFoot.addCell(rightFootCell);

        document.add(tblFoot);

        //
        document.close();
        JOptionPane.showMessageDialog(null, "In hoadon.pdf thnh cng");
        return true;
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null,
                "hoadon.pdf ang c m\nVui lng ng li. Sau  th li");
        e.printStackTrace();
        return false;
    }
}

From source file:ro.nextreports.engine.exporter.PdfExporter.java

License:Apache License

private PdfPCell renderPdfCell(BandElement bandElement, Object value, int gridRow, int rowSpan, int colSpan,
        boolean image, int column) {
    Map<String, Object> style = buildCellStyleMap(bandElement, value, gridRow, column, colSpan);

    FontFactoryImp fact = new FontFactoryImp();
    com.itextpdf.text.Font fnt;//from ww  w  . java 2s  . c  o m
    if (bandElement != null) {
        fontName = (String) style.get(StyleFormatConstants.FONT_NAME_KEY);
        int size = ((Float) style.get(StyleFormatConstants.FONT_SIZE)).intValue();
        fnt = getFont(size);
    } else {
        fnt = getFont(10);
    }

    PdfPCell cell;
    if (image) {
        if (value == null) {
            cell = new PdfPCell(new Phrase(IMAGE_NOT_FOUND));
        } else {
            ImageBandElement ibe = (ImageBandElement) bandElement;
            try {
                byte[] imageBytes = getImage((String) value);
                cell = getImageCell(ibe, imageBytes, column, colSpan);
            } catch (Exception e) {
                cell = new PdfPCell(new Phrase(IMAGE_NOT_LOADED));
            }
        }
    } else if (bandElement instanceof HyperlinkBandElement) {
        Hyperlink hyperlink = ((HyperlinkBandElement) bandElement).getHyperlink();
        Anchor anchor = new Anchor(hyperlink.getText(), fnt);
        anchor.setReference(hyperlink.getUrl());
        Phrase ph = new Phrase();
        ph.add(anchor);
        cell = new PdfPCell(ph);
    } else if (bandElement instanceof ReportBandElement) {
        Report report = ((ReportBandElement) bandElement).getReport();
        ExporterBean eb = null;
        try {
            eb = getSubreportExporterBean(report);
            PdfExporter subExporter = new PdfExporter(eb);
            subExporter.export();
            PdfPTable innerTable = subExporter.getTable();
            cell = new PdfPCell(innerTable);
        } catch (Exception e) {
            cell = new PdfPCell();
            e.printStackTrace();
        } finally {
            if ((eb != null) && (eb.getResult() != null)) {
                eb.getResult().close();
            }
        }
    } else if ((bandElement instanceof VariableBandElement) && (VariableFactory
            .getVariable(((VariableBandElement) bandElement).getVariable()) instanceof TotalPageNoVariable)) {
        try {
            cell = new PdfPCell(Image.getInstance(total));
        } catch (BadElementException e) {
            cell = new PdfPCell(new Phrase("NA"));
        }

    } else if (bandElement instanceof ImageColumnBandElement) {
        try {
            String v = StringUtil.getValueAsString(value, null);
            if (StringUtil.BLOB.equals(v)) {
                cell = new PdfPCell(new Phrase(StringUtil.BLOB));
            } else {
                byte[] bytes = StringUtil.decodeImage(v);
                cell = getImageCell(bandElement, bytes, column, colSpan);
            }
        } catch (Exception e) {
            e.printStackTrace();
            cell = new PdfPCell(new Phrase(IMAGE_NOT_LOADED));
        }
    } else {
        String stringValue;
        if (style.containsKey(StyleFormatConstants.PATTERN)) {
            stringValue = StringUtil.getValueAsString(value, (String) style.get(StyleFormatConstants.PATTERN),
                    getReportLanguage());
        } else {
            stringValue = StringUtil.getValueAsString(value, null, getReportLanguage());
        }
        if (stringValue == null) {
            stringValue = "";
        }
        if (stringValue.startsWith("<html>")) {
            StringReader reader = new StringReader(stringValue);
            List<Element> elems = new ArrayList<Element>();
            try {
                elems = HTMLWorker.parseToList(reader, new StyleSheet());
                Phrase ph = new Phrase();
                for (int i = 0; i < elems.size(); i++) {
                    Element elem = (Element) elems.get(i);
                    ph.add(elem);
                }
                cell = new PdfPCell(ph);
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                Phrase ph = new Phrase(stringValue, fnt);
                cell = new PdfPCell(ph);
            }

        } else {
            Phrase ph = new Phrase(stringValue, fnt);
            cell = new PdfPCell(ph);
        }
    }

    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    cell.setUseDescender(true); // needed for a cell without padding
    cell.setMinimumHeight(MINIMUM_HEIGHT); // needed if there is a row in which all cells are empty

    if (bandElement != null) {
        cell.setRotation(bandElement.getTextRotation());
    }

    if (colSpan > 1) {
        cell.setColspan(colSpan);
    }

    if (rowSpan > 1) {
        cell.setRowspan(rowSpan);
    }

    if (style != null) {

        updateFont(style, fnt);

        if (style.containsKey(StyleFormatConstants.BACKGROUND_COLOR)) {
            Color val = (Color) style.get(StyleFormatConstants.BACKGROUND_COLOR);
            cell.setBackgroundColor(new BaseColor(val));
        }
        if (style.containsKey(StyleFormatConstants.HORIZONTAL_ALIGN_KEY)) {
            if (StyleFormatConstants.HORIZONTAL_ALIGN_LEFT
                    .equals(style.get(StyleFormatConstants.HORIZONTAL_ALIGN_KEY))) {
                cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
            }
            if (StyleFormatConstants.HORIZONTAL_ALIGN_RIGHT
                    .equals(style.get(StyleFormatConstants.HORIZONTAL_ALIGN_KEY))) {
                cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            }
            if (StyleFormatConstants.HORIZONTAL_ALIGN_CENTER
                    .equals(style.get(StyleFormatConstants.HORIZONTAL_ALIGN_KEY))) {
                cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            }
        }

        if (style.containsKey(StyleFormatConstants.VERTICAL_ALIGN_KEY)) {
            if (StyleFormatConstants.VERTICAL_ALIGN_TOP
                    .equals(style.get(StyleFormatConstants.VERTICAL_ALIGN_KEY))) {
                cell.setVerticalAlignment(Element.ALIGN_TOP);
            }
            if (StyleFormatConstants.VERTICAL_ALIGN_MIDDLE
                    .equals(style.get(StyleFormatConstants.VERTICAL_ALIGN_KEY))) {
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            }
            if (StyleFormatConstants.VERTICAL_ALIGN_BOTTOM
                    .equals(style.get(StyleFormatConstants.VERTICAL_ALIGN_KEY))) {
                cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
            }
        }

        if (style.containsKey(StyleFormatConstants.PADDING_LEFT)) {
            Float val = (Float) style.get(StyleFormatConstants.PADDING_LEFT);
            cell.setPaddingLeft(val);
        }
        if (style.containsKey(StyleFormatConstants.PADDING_RIGHT)) {
            Float val = (Float) style.get(StyleFormatConstants.PADDING_RIGHT);
            cell.setPaddingRight(val);
        }
        if (style.containsKey(StyleFormatConstants.PADDING_TOP)) {
            Float val = (Float) style.get(StyleFormatConstants.PADDING_TOP);
            cell.setPaddingTop(val);
        }
        if (style.containsKey(StyleFormatConstants.PADDING_BOTTOM)) {
            Float val = (Float) style.get(StyleFormatConstants.PADDING_BOTTOM);
            cell.setPaddingBottom(val);
        }
        cell.setBorderWidth(0);

        if (style.containsKey(StyleFormatConstants.BORDER_LEFT)) {
            Float val = (Float) style.get(StyleFormatConstants.BORDER_LEFT);
            cell.setBorderWidthLeft(val / 2);
            Color color = (Color) style.get(StyleFormatConstants.BORDER_LEFT_COLOR);
            cell.setBorderColorLeft(new BaseColor(color));
        }
        if (style.containsKey(StyleFormatConstants.BORDER_RIGHT)) {
            Float val = (Float) style.get(StyleFormatConstants.BORDER_RIGHT);
            cell.setBorderWidthRight(val / 2);
            Color color = (Color) style.get(StyleFormatConstants.BORDER_RIGHT_COLOR);
            cell.setBorderColorRight(new BaseColor(color));
        }
        if (style.containsKey(StyleFormatConstants.BORDER_TOP)) {
            Float val = (Float) style.get(StyleFormatConstants.BORDER_TOP);
            cell.setBorderWidthTop(val / 2);
            Color color = (Color) style.get(StyleFormatConstants.BORDER_TOP_COLOR);
            cell.setBorderColorTop(new BaseColor(color));
        }
        if (style.containsKey(StyleFormatConstants.BORDER_BOTTOM)) {
            Float val = (Float) style.get(StyleFormatConstants.BORDER_BOTTOM);
            cell.setBorderWidthBottom(val / 2);
            Color color = (Color) style.get(StyleFormatConstants.BORDER_BOTTOM_COLOR);
            cell.setBorderColorBottom(new BaseColor(color));
        }

        // for subreports we use default no wrap
        if (cell.getTable() == null) {
            cell.setNoWrap(true);
            if (bandElement != null) {
                if (bandElement.isWrapText()) {
                    cell.setNoWrap(false);
                }
            }
        }

        // to see a background image all cells must not have any background!
        if (bean.getReportLayout().getBackgroundImage() != null) {
            cell.setBackgroundColor(null);
        }
    }
    return cell;
}