Example usage for com.itextpdf.text.pdf BaseFont createFont

List of usage examples for com.itextpdf.text.pdf BaseFont createFont

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf BaseFont createFont.

Prototype

public static BaseFont createFont(String name, String encoding, boolean embedded)
        throws DocumentException, IOException 

Source Link

Document

Creates a new font.

Usage

From source file:hsa.awp.admingui.report.printer.MergePDFUtil.java

License:Open Source License

private BaseFont getBaseFont() throws DocumentException, IOException {
    return BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
}

From source file:htmlparser.pdf.PDFFile.java

public PDFFile(Parser parser) {

    this.parser = parser;
    this.document = new Document();

    try {//from   w  ww . ja va  2 s . com

        PdfWriter.getInstance(this.document, new FileOutputStream(this.parser.getCompetitionName() + ".pdf"));
        this.document.open();
        this.fonttype = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED);
        this.opened = true;

    } catch (Exception ex) {
        this.opened = false;
    }
}

From source file:jasperSoft.MergePDF.java

/**
 * //from   w w w  .  j a  v a2s . co  m
 * @param streamOfPDFFiles
 * @param outputStream
 * @param paginate 
 */
public static void concatPDFs(List<InputStream> streamOfPDFFiles, OutputStream outputStream, boolean paginate) {

    Document document = new Document();
    try {
        List<InputStream> pdfs = streamOfPDFFiles;
        List<PdfReader> readers = new ArrayList<PdfReader>();
        int totalPages = 0;
        Iterator<InputStream> iteratorPDFs = pdfs.iterator();

        // Create Readers for the pdfs.
        while (iteratorPDFs.hasNext()) {
            InputStream pdf = iteratorPDFs.next();
            PdfReader pdfReader = new PdfReader(pdf);
            readers.add(pdfReader);
            totalPages += pdfReader.getNumberOfPages();
        }
        // Create a writer for the outputstream
        PdfWriter writer = PdfWriter.getInstance(document, outputStream);

        document.open();
        BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
        PdfContentByte cb = writer.getDirectContent(); // Holds the PDF
        // data

        PdfImportedPage page;
        int currentPageNumber = 0;
        int pageOfCurrentReaderPDF = 0;
        Iterator<PdfReader> iteratorPDFReader = readers.iterator();

        // Loop through the PDF files and add to the output.
        while (iteratorPDFReader.hasNext()) {
            PdfReader pdfReader = iteratorPDFReader.next();

            // Create a new page in the target for each source page.
            while (pageOfCurrentReaderPDF < pdfReader.getNumberOfPages()) {
                document.newPage();
                pageOfCurrentReaderPDF++;
                currentPageNumber++;
                page = writer.getImportedPage(pdfReader, pageOfCurrentReaderPDF);
                cb.addTemplate(page, 0, 0);

                // Code for pagination.
                if (paginate) {
                    cb.beginText();
                    cb.setFontAndSize(bf, 9);
                    cb.showTextAligned(PdfContentByte.ALIGN_CENTER,
                            "" + currentPageNumber + " of " + totalPages, 520, 5, 0);
                    cb.endText();
                }
            }
            pageOfCurrentReaderPDF = 0;
        }
        outputStream.flush();
        document.close();
        outputStream.close();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        if (document.isOpen()) {
            document.close();
        }
        try {
            if (outputStream != null) {
                outputStream.close();
            }
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
    }
}

From source file:jati.GerandoArquivoCarimbado.java

public static void GerandoArquivoCarimbadoPDF(String caminhoarquivo, String BN)
        throws InvalidPdfException, IOException {
    //Copiando arquivo informado.

    try {//from   w  w w  .  j a v  a  2s.c  o  m

        // Adicionado parametro para nao retornar erro quando o documento for protegido.
        PdfReader.unethicalreading = true;

        PdfWriter writer = PdfWriter.getInstance(montaraAquivo(caminhoarquivo),
                new FileOutputStream(caminhoarquivo.substring(0, caminhoarquivo.length() - 4) + "-C.pdf"));
        // ABRE O DOCUMENTO CRIADO PARA MANUSEIO
        montaraAquivo(caminhoarquivo).open();

        //SUBSTRING RETIRA PARTE DO TEXTO ENTRE OS INDICES ESPECIFICADOS 
        //caminhoDestino RECEBE UM NOVO CAMINHO RESULTANTE DOS INDICES DE CAMINHO.LENGTH - BN.LENGTH
        // QUE FORMAM UMA NOVA STRING
        String caminhodestino = (caminhoarquivo.substring(0, caminhoarquivo.length() - BN.length()));

        File destinooriginal = new File(caminhodestino + "ORIGINAL\\");
        if (!destinooriginal.exists()) {
            destinooriginal.mkdir();
        }

        caminhodestino = (caminhodestino + "ORIGINAL\\" + BN);

        //TESTANDO NOVA FORMA DE COPIAR
        File origem = new File(caminhoarquivo);
        File destino = new File(caminhodestino);

        FileInputStream fis = new FileInputStream(origem);
        FileOutputStream fos = new FileOutputStream(destino);

        FileChannel inChannel = fis.getChannel();
        FileChannel outChannel = fos.getChannel();

        long transferFrom = outChannel.transferFrom(inChannel, 0, inChannel.size());

        fis.close();
        fos.close();
        inChannel.close();
        outChannel.close();

        // Thread.sleep(10);
        BN = BN.substring(0, BN.length() - 4);

        PdfContentByte cb = writer.getDirectContent();

        int i = 0;
        while (i < reader.getNumberOfPages()) {
            montaraAquivo(caminhodestino).newPage();

            i++;

            //PDFCONTETBYTE GERA UMA ESPECIE DE CODIGO DE BARRAS 
            PdfContentByte under = writer.getDirectContentUnder();
            PdfImportedPage page1 = writer.getImportedPage(reader, i);
            cb.addTemplate(page1, 0, i * 0.2f);

            //CARIMBO DA BN
            BaseFont bf = BaseFont.createFont(BaseFont.COURIER_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED);
            cb.beginText();
            cb.setFontAndSize(bf, 14);
            cb.showTextAligned(PdfContentByte.ALIGN_CENTER, " ________________", width / 6, 44, 0);
            cb.showTextAligned(PdfContentByte.ALIGN_CENTER, " |               |", width / 6, 32, 0);
            cb.showTextAligned(PdfContentByte.ALIGN_CENTER, " |               |", width / 6, 22, 0);
            cb.showTextAligned(PdfContentByte.ALIGN_CENTER, " NR", width / 6, 28, 0);
            cb.showTextAligned(PdfContentByte.ALIGN_CENTER, " " + BN, width / 6, 16, 0);
            cb.showTextAligned(PdfContentByte.ALIGN_CENTER, " |               |", width / 6, 12, 0);
            cb.showTextAligned(PdfContentByte.ALIGN_CENTER, " ________________", width / 6, 14, 0);
            cb.endText();

        }

        montaraAquivo(caminhodestino).close();
        writer.close();
        reader.close();
        origem.delete();

    } catch (IOException | DocumentException ex) {
    }

}

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

License:Apache License

private BaseFont getDefaultBaseFont() throws DocumentException, IOException {
    if (getDefaultFont() != null) {
        return BaseFont.createFont(getDefaultFont(), BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
    }//from   w w w  .j  a  va 2 s  . co  m
    return null;
}

From source file:KTCNPM.ExportFile.java

public void exportFile(ArrayList<String> list, ArrayList<String> listTAW, ArrayList<String> listTBF,
        ArrayList<String> listTCF, ArrayList<String> listEF, ArrayList<String> listG) throws IOException {
    Document document = new Document();

    try {/*from ww  w  .  j av  a 2  s .com*/
        String fileSRC = "E:\\KTCNPM.pdf";
        File file = new File(fileSRC);
        if (file.exists()) {
            file.delete();
        } else {
            file.createNewFile();
        }

        PdfWriter.getInstance(document, new FileOutputStream(fileSRC));
        document.open();

        Font f1 = new Font(
                BaseFont.createFont("/newpackage/vuArialBold.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED));
        Font f2 = new Font(
                BaseFont.createFont("/newpackage/vuArial.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED));
        f2.setSize(9);
        f1.setSize(13);

        Paragraph paragraph2 = new Paragraph("", f2);
        Paragraph paragraph3 = new Paragraph();

        paragraph2.setIndentationLeft(80);
        paragraph2.setIndentationRight(80);
        paragraph2.setAlignment(Element.ALIGN_LEFT);
        paragraph2.setSpacingAfter(15);

        Phrase phrase2 = new Phrase("Tn phn m?m: Tnh chi ph phn m?m");
        Phrase phrase3 = new Phrase(" ");
        paragraph3.add(phrase3);
        paragraph2.add(phrase2);

        //Phu luc 3
        Phrase phrase5 = new Phrase(
                "Ph lc III: Bng tnh ton im cc tc nhn (actors) tng tc, trao i thng tin");
        Paragraph paragraph5 = new Paragraph("", f1);
        paragraph5.setIndentationLeft(80);
        paragraph5.setIndentationRight(80);
        paragraph5.setAlignment(Element.ALIGN_CENTER);
        paragraph5.setSpacingAfter(10);
        paragraph5.add(phrase5);

        document.add(paragraph5);
        document.add(paragraph2);

        PdfPTable table3 = new PdfPTable(5);

        table3.setWidthPercentage(400 / 5.23f);
        table3.setWidths(new int[] { 1, 5, 3, 2, 3 });
        for (int i = 0; i < listTAW.size(); i++) {
            Paragraph p = new Paragraph(listTAW.get(i), f2);
            PdfPCell data = new PdfPCell(p);
            table3.addCell(data);
        }
        document.add(table3);
        document.add(paragraph3);
        document.add(paragraph3);
        document.add(paragraph3);

        // phu luc 4
        Phrase phrase41 = new Phrase(
                "Ph lc IV: Bng tnh ton im cc tr?ng hp s dung (use case)");
        Paragraph paragraph41 = new Paragraph("", f1);
        paragraph41.setIndentationLeft(80);
        paragraph41.setIndentationRight(80);
        paragraph41.setAlignment(Element.ALIGN_CENTER);
        paragraph41.setSpacingAfter(10);
        paragraph41.add(phrase41);

        document.add(paragraph41);
        document.add(paragraph2);

        PdfPTable table4 = new PdfPTable(4);
        table4.setWidthPercentage(400 / 5.23f);
        table4.setWidths(new int[] { 1, 3, 3, 4 });
        for (int i = 0; i < listTBF.size(); i++) {
            PdfPCell data = new PdfPCell(new Paragraph(listTBF.get(i), f2));
            table4.addCell(data);
        }
        document.add(table4);
        document.add(paragraph3);
        document.add(paragraph3);
        document.add(paragraph3);

        // phu luc 5
        Phrase phrase51 = new Phrase(
                "Ph lc V: Bng tnh ton h s phc tp k thut - cng ngh");
        Paragraph paragraph51 = new Paragraph("", f1);
        paragraph51.setIndentationLeft(80);
        paragraph51.setIndentationRight(80);
        paragraph51.setAlignment(Element.ALIGN_CENTER);
        paragraph51.setSpacingAfter(10);
        paragraph51.add(phrase51);

        document.add(paragraph51);
        document.add(paragraph2);

        PdfPTable table5 = new PdfPTable(5);
        table5.setWidthPercentage(400 / 5.23f);
        table5.setWidths(new int[] { 1, 6, 2, 2, 2 });
        for (int i = 0; i < listTCF.size(); i++) {
            PdfPCell data = new PdfPCell(new Paragraph(listTCF.get(i), f2));
            table5.addCell(data);
        }
        document.add(table5);
        document.add(paragraph3);
        document.add(paragraph3);
        document.add(paragraph3);

        //phu luc 6
        Phrase phrase61 = new Phrase(
                "Ph lc VI: Bng tnh ton h s tc ng mi tr?ng v nhm lm vic, h s phc tp v? mi tr?ng");
        Paragraph paragraph61 = new Paragraph("", f1);
        paragraph61.setIndentationLeft(80);
        paragraph61.setIndentationRight(80);
        paragraph61.setAlignment(Element.ALIGN_CENTER);
        paragraph61.setSpacingAfter(10);
        paragraph61.add(phrase61);

        document.add(paragraph61);
        document.add(paragraph2);

        PdfPTable table6 = new PdfPTable(6);
        table6.setWidthPercentage(400 / 5.23f);
        table6.setWidths(new int[] { 1, 6, 2, 2, 2, 3 });
        for (int i = 0; i < listEF.size(); i++) {
            PdfPCell data = new PdfPCell(new Paragraph(listEF.get(i), f2));
            table6.addCell(data);
        }
        document.add(table6);
        document.add(paragraph3);
        document.add(paragraph3);
        document.add(paragraph3);

        //phu luc 7
        Phrase phrase7 = new Phrase("Ph lc VII: Bng tnh ton gi tr phn m?m");
        Paragraph paragraph7 = new Paragraph("", f1);
        paragraph7.setIndentationLeft(80);
        paragraph7.setIndentationRight(80);
        paragraph7.setAlignment(Element.ALIGN_CENTER);
        paragraph7.setSpacingAfter(10);
        paragraph7.add(phrase7);

        document.add(paragraph7);
        document.add(paragraph2);

        PdfPTable table7 = new PdfPTable(5);
        table7.setWidthPercentage(400 / 5.23f);
        table7.setWidths(new int[] { 1, 5, 5, 4, 2 });
        for (int i = 0; i < listG.size(); i++) {
            PdfPCell data = new PdfPCell(new Paragraph(listG.get(i), f2));
            table7.addCell(data);
        }
        document.add(table7);
        document.add(paragraph3);
        document.add(paragraph3);
        document.add(paragraph3);

        // phu luc 8
        Paragraph paragraph1 = new Paragraph("", f1);
        paragraph1.setIndentationLeft(80);
        paragraph1.setIndentationRight(80);
        paragraph1.setAlignment(Element.ALIGN_CENTER);
        paragraph1.setSpacingAfter(10);
        Phrase phrase1 = new Phrase("Ph lc VIII: Bng tng hp chi ph phn m?m");
        paragraph1.add(phrase1);
        document.add(paragraph1);
        document.add(paragraph2);
        PdfPTable table = new PdfPTable(5);
        table.setWidthPercentage(400 / 5.23f);
        table.setWidths(new int[] { 1, 5, 3, 4, 2 });

        for (int i = 0; i < list.size(); i++) {
            PdfPCell data = new PdfPCell(new Paragraph(list.get(i), f2));
            table.addCell(data);
        }
        document.add(table);
        document.close();

    } catch (DocumentException | FileNotFoundException e) {
    }
}

From source file:Logic.DocsCreation.java

public void createPdfDoc(JTable Table, GetPatientData data, StartDB con, boolean flag,
        ArrayList<String> arrPatient, String crb) {
    try {//from w  ww . j  a  v a2s .c  om
        norm.getNorm(con.getConnection());
        int b = arrPatient.size();
        if (b == -1) {
            return;
        }
        String path = System.getProperty("user.home");
        path = path + "//Desktop//";
        File theDir = new File(path, "???");
        // if the directory does not exist, create it
        if (!theDir.exists()) {

            boolean result = false;

            try {
                theDir.mkdir();
                result = true;
            } catch (SecurityException se) {
                //handle it
            }
            if (result) {
                System.out.println("DIR created");
            }
        }
        for (int k = 0; k < b; k++) {
            String id = arrPatient.get(k);//Table.getModel().getValueAt(k, 0).toString(); 
            data = new GetPatientData();
            data.getMainData(con.getConnection(), id, crb);
            data.getPatientDocs(con.getConnection(), id);
            String[] arr = null;
            String fname = data.getName().replaceAll(" ", "") + data.getBirth();

            Document doc = new Document();
            String fileName = path + "\\???\\" + fname + ".pdf";
            String pdfName = "";
            FileOutputStream fos = new FileOutputStream(fileName);
            PdfWriter.getInstance(doc, fos);
            doc.open();

            BaseFont bf = BaseFont.createFont("C:\\Windows\\Fonts\\ARIAL.TTF", BaseFont.IDENTITY_H,
                    BaseFont.EMBEDDED);
            BaseFont bfn = BaseFont.createFont("C:\\Windows\\Fonts\\ARIALI.TTF", BaseFont.IDENTITY_H,
                    BaseFont.EMBEDDED);
            // 
            Paragraph title = new Paragraph(data.getCrbName() + "\n", new Font(bf, 16, Font.BOLD));
            title.setAlignment(Element.ALIGN_CENTER);
            doc.add(title);
            // ? 
            Paragraph lpu = new Paragraph("?   " + data.getLpu(), new Font(bf, 12));
            lpu.setAlignment(Element.ALIGN_RIGHT);
            doc.add(lpu);
            doc.add(new Phrase(
                    "____________________________________________________________________________________\n",
                    new Font(bf, 11, Font.BOLD)));

            doc.add(new Phrase(": ", new Font(bf, 13, Font.BOLD)));
            doc.add(new Phrase(data.getName() + " (" + data.getSex() + ")\n", new Font(bf, 13)));
            doc.add(new Phrase(" ?: ", new Font(bf, 13, Font.BOLD)));
            doc.add(new Phrase(data.getBirth() + "\n", new Font(bf, 13)));
            doc.add(new Phrase(" ? ??: ",
                    new Font(bf, 13, Font.BOLD)));
            doc.add(new Phrase(data.getDate() + "\n", new Font(bf, 13)));

            if (data.getSnils() != null) {
                doc.add(new Phrase("? : ", new Font(bf, 13, Font.BOLD)));
                doc.add(new Phrase(data.getSnils() + "\n", new Font(bf, 13)));
            }
            if (data.getDocs() != null) {
                doc.add(new Phrase(": ", new Font(bf, 13, Font.BOLD)));
                doc.add(new Phrase(data.getDocs() + " ", new Font(bf, 13)));
                ;
            }
            if (data.getPolicy() != null) {
                doc.add(new Phrase(" ?: ", new Font(bf, 13, Font.BOLD)));
                doc.add(new Phrase(data.getPolicy() + "; ", new Font(bf, 13)));
            }

            if (data.getPhone() != null) {
                doc.add(new Phrase("?  ", new Font(bf, 13, Font.BOLD)));
                doc.add(new Phrase(data.getPhone() + "; ", new Font(bf, 13)));
            }
            //  ?

            data.getDoneServiceCount(con.getConnection(), id);
            data.getDoneServiceData(con.getConnection(), id);
            // data.getDoneServiceProp(con.getConnection(), id,data.getService_code().get(k));
            //  ?
            doc.add(new Paragraph("\n ?: \n", new Font(bf, 16, Font.BOLD)));

            for (int i = 0; i < data.getCount(); i++) {
                data.getDoneServiceProp(con.getConnection(), id, data.getService_code().get(i));
                doc.add(new Phrase(data.getService_name().get(i) + " : \n", new Font(bf, 12, Font.BOLD)));
                if (data.getService_result().get(i) != null) {
                    arr = data.getService_result().get(i).split(";");

                    for (int l = 0; l < norm.getCode().size(); l++) {
                        if (data.getService_code().get(i).equals(norm.getCode().get(l))) {
                            flagExistNorm = true;
                            if ("".equals(data.getSex()))
                                arrNorm = norm.getNormsWoman().get(l).split(";");
                            else if ("".equals(data.getSex())) {
                                arrNorm = norm.getNormsMan().get(l).split(";");
                            }

                            break;
                        } else
                            flagExistNorm = false;
                    }

                    //<editor-fold defaultstate="collapsed" desc="?? ?? ">
                    //                switch(data.getService_name().get(i)){            
                    //                    
                    //                    case "01.?()":
                    //                    doc.add(new Phrase("  ? - " +arr[0]+ " ;\n " ,new Font(bf, 12)));
                    //                    break;
                    //                    
                    //                    case "02.??":                 
                    //                        doc.add(new Phrase("? - " + arr[0] +" ; ",new Font(bf, 12)));
                    //                        doc.add(new Phrase("? - " + arr[2] +" ; ",new Font(bf, 12)));
                    //                        doc.add(new Phrase("?  - " + arr[1] +" ;\n ",new Font(bf, 12)));               
                    //                        break; 
                    //
                    //                    case "03.  ?":                 
                    //                        doc.add(new Phrase("   - " + arr[0] +" ; ",new Font(bf, 12)));
                    //                        doc.add(new Phrase("?   - " + arr[1] +" ;",new Font(bf, 12)));
                    //                        doc.add(new Phrase("? - " + arr[2] +" ;\n ",new Font(bf, 12)));
                    //                        break; 
                    //
                    //                     case "06.?  " :                 
                    //                            
                    //                     {   
                    //                            doc.add(new Phrase("  " +";\n ",new Font(bf, 12)));
                    //                            pdfName = "C:\\MDKTemp\\"+fname+"ECG.pdf";
                    //                            try (OutputStream targetFile = new FileOutputStream(pdfName)) {
                    //                            targetFile.write(data.getPDFData(con.getConnection(), id));
                    //                            targetFile.close();
                    //                            log.info("pdf  ? "+id+ "?");
                    //                            } catch (Exception ex) {
                    //                                    log.error(ex, ex);                            
                    //                            }
                    //                        }
                    //                     break;         
                    //
                    //                     case "08.? ":                 
                    //                        doc.add(new Phrase(" ?? - " + arr[0] +" ;\n",new Font(bf, 12)));               
                    //                        break; 
                    //
                    //                     case "13.  ":                 
                    //                        doc.add(new Phrase("\n (), / - " + arr[0] +" ; \n",new Font(bf, 12)));
                    //                        doc.add(new Phrase(", /- " + arr[1] +" ; \n",new Font(bf, 12)));
                    //                        doc.add(new Phrase(", / - " + arr[2] +" - \n",new Font(bf, 12)));
                    //                        doc.add(new Phrase(" (),-/ - " + arr[3] +" ; \n",new Font(bf, 12)));
                    //                        doc.add(new Phrase(" (), -/ - " + arr[4] +" ; \n",new Font(bf, 12)));
                    //                        doc.add(new Phrase("? ? - " + arr[5] +" ; \n",new Font(bf, 12)));
                    //                        doc.add(new Phrase("pH - " + arr[6] +" ; \n",new Font(bf, 12)));
                    //                        doc.add(new Phrase(", / - " + arr[7] +" ; \n",new Font(bf, 12)));
                    //                        doc.add(new Phrase("??? ?, / - " + arr[8] +" ; \n",new Font(bf, 12)));
                    //                        doc.add(new Phrase("? - " + arr[9] +" ; \n",new Font(bf, 12)));
                    //                        doc.add(new Phrase(" (), / - " + arr[10] +" ; \n",new Font(bf, 12)));
                    //                        doc.add(new Phrase(" - " + arr[11] +" ; \n",new Font(bf, 12)));
                    //                        doc.add(new Phrase("? - " + arr[12] +" ;\n",new Font(bf, 12)));
                    //                        break; 
                    //
                    //                        case "16.  ?":                 
                    //                        doc.add(new Phrase(" - " + arr[0] +" ;",new Font(bf, 12)));
                    //                        doc.add(new Phrase(" - " + arr[1] +" ;",new Font(bf, 12)));                
                    //                        break;
                    //                    } 
                    //</editor-fold>    
                    //            
                    int arrSize = arr.length;
                    for (int j = 0; (j < arrSize); j++) {

                        if (data.getService_name().get(i).contains("?")
                                || data.getService_name().get(i).contains("")) {
                            doc.add(new Phrase("  " + ";\n ", new Font(bf, 12)));
                            pdfName = "C:\\MDKTemp\\" + fname + "ECG.pdf";
                            try (OutputStream targetFile = new FileOutputStream(pdfName)) {
                                targetFile.write(data.getPDFData(con.getConnection(), id));
                                targetFile.close();
                                log.info("pdf  ? " + id + "?");

                                break;
                            } catch (Exception ex) {
                                log.error(ex, ex);
                            }
                        }
                        if (flagExistNorm) {
                            String[] border;
                            border = new String[2];

                            border = arrNorm[j].split(" - ");
                            if (Float.parseFloat(arr[j]) >= Float.parseFloat(border[0])) {
                                if (Float.parseFloat(arr[j]) <= Float.parseFloat(border[1])) {
                                    //   ?

                                    doc.add(new Phrase(data.getService_prop().get(j) + " - " + arr[j] + " ;\n",
                                            new Font(bf, 12)));
                                } else {
                                    //    
                                    doc.add(new Phrase(data.getService_prop().get(j) + " - " + arr[j] + " ; ",
                                            new Font(bf, 12, Font.UNDERLINE)));
                                    if (border[0].equals(border[1])) {
                                        doc.add(new Phrase("! (? " + border[0] + ");\n",
                                                new Font(bfn, 12, Font.UNDERLINE)));
                                    } else
                                        doc.add(new Phrase(
                                                "! (? " + border[0] + " - " + border[1] + ");\n",
                                                new Font(bfn, 12, Font.UNDERLINE)));
                                }
                            } else {
                                //    
                                doc.add(new Phrase(data.getService_prop().get(j) + " - " + arr[j] + " ; ",
                                        new Font(bf, 12, Font.UNDERLINE)));
                                if (border[0].equals(border[1])) {
                                    doc.add(new Phrase("! (? " + border[0] + ");\n",
                                            new Font(bfn, 12, Font.UNDERLINE)));
                                } else
                                    doc.add(new Phrase(
                                            "! (? " + border[0] + " - " + border[1] + ");\n",
                                            new Font(bfn, 12, Font.UNDERLINE)));
                            }
                        } else
                            doc.add(new Phrase(data.getService_prop().get(j) + " - " + arr[j] + " ;\n",
                                    new Font(bf, 12)));

                    }

                }
            }
            //  ?
            data.getAppoitedServiceCount(con.getConnection(), id);
            data.getAppServiceData(con.getConnection(), id);
            doc.add(new Phrase("? ? :\n", new Font(bf, 16, Font.BOLD)));
            for (int j = 0; j < data.getCount(); j++) {
                if (data.getService_result().get(j) != null) {
                    doc.add(new Phrase(data.getService_name().get(j) + " - ", new Font(bf, 12, Font.BOLD)));
                    doc.add(new Phrase(data.getService_result().get(j) + " ; ", new Font(bf, 12)));
                }
                if (data.getService_result().get(j) == null) {
                    doc.add(new Phrase(data.getService_name().get(j) + " ; ", new Font(bf, 12, Font.BOLD)));
                }
            }
            // 
            data.getRenServiceCount(con.getConnection(), id);
            data.getRenServiceData(con.getConnection(), id);
            doc.add(new Phrase("\n : ", new Font(bf, 16, Font.BOLD)));
            for (int i = 0; i < data.getCount(); i++) {
                if (data.getService_name().get(i) == null) {
                    doc.add(new Phrase("? ", new Font(bf, 12)));
                }
                doc.add(new Phrase(data.getService_name().get(i) + " ; ", new Font(bf, 12, Font.BOLD)));
            }
            // 
            data.getEarlierServiceCount(con.getConnection(), id);
            data.getEarServiceData(con.getConnection(), id);
            doc.add(new Phrase("\n  : ", new Font(bf, 16, Font.BOLD)));
            for (int i = 0; i < data.getCount(); i++) {
                if (data.getService_result().get(i) != null) {
                    doc.add(new Phrase(data.getService_name().get(i) + " - ", new Font(bf, 12, Font.BOLD)));
                    doc.add(new Phrase(data.getService_date().get(i) + " ; ", new Font(bf, 12)));
                }
                if (data.getService_result().get(i) == null) {
                    doc.add(new Phrase(data.getService_name().get(i) + " ;", new Font(bf, 12)));
                }

            }
            doc.close();
            if (!flag) {
                if (!pdfName.equals("")) {
                    AddCover1 cov = new AddCover1();
                    String tempFile = fileName;
                    String ECGFile = pdfName;
                    String res = path + "//???//" + fname + "ECG.pdf";
                    File file = new File(res);
                    file.getParentFile().mkdirs();
                    cov.manipulatePdf(ECGFile, res, tempFile);
                    File dfile = new File(fileName);
                    if (dfile.delete()) {
                        System.out.println(dfile.getName() + " is deleted!");
                    } else {
                        System.out.println("Delete operation is failed.");
                    }

                }
            }

            if (flag) {
                if (!pdfName.equals("")) {
                    AddCover1 cov = new AddCover1();
                    String tempFile = fileName;
                    String ECGFile = pdfName;
                    String res = "C:\\" + fname + "ECG.pdf";
                    File file = new File(res);
                    file.getParentFile().mkdirs();
                    cov.manipulatePdf(ECGFile, res, tempFile);
                    File dfile = new File(fileName);
                    if (dfile.delete()) {
                        System.out.println(dfile.getName() + " is deleted!");
                    } else {
                        System.out.println("Delete operation is failed.");
                    }

                    File pfile = new File(res);
                    try {
                        Desktop.getDesktop().print(pfile);
                        Thread.sleep(2000);
                    } catch (IOException ex) {
                        log.error(ex, ex);
                    }
                } else {
                    File pfile = new File(fileName);
                    try {
                        Desktop.getDesktop().print(pfile);
                        Thread.sleep(2000);
                    } catch (IOException ex) {
                        log.error(ex, ex);
                    }
                }
            }
        }
    } catch (Exception e) {
        log.error(e, e);
    }

}

From source file:main.ItextPDF.java

public void createPdf(String filename, Person person) {
    // step 1/*ww  w  . j a  va2  s .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 . jav  a 2s.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:Model.MyFontSelector.java

License:Open Source License

/**
 * Inits the BaseFonts of External Fonts and gets of the internals
 * Faz a inicializao das BaseFonts das fontes externas e recupera das
 * fontes internas.//w  w w  .  ja v a  2  s  .c  o  m
 */
private void initBaseFonts() {
    try {
        ArrayList<BaseFont> baseFontList = new ArrayList<>();
        ArrayList<Font> fontList = new ArrayList<>();

        /**
         * Gets Internals BaseFonts
         * Recupera as BaseFonts das fontes internas
         */
        fontList.add(FontFactory.getFont(BaseFont.TIMES_ROMAN));
        fontList.add(FontFactory.getFont(BaseFont.COURIER));
        fontList.add(FontFactory.getFont(BaseFont.SYMBOL));

        for (Font f : fontList) {
            baseFontList.add(f.getBaseFont());
        }

        /**
         * Gets external chinese traditional BaseFonts
         * Recupera as BaseFonts da fonte externa do Chins tradicional
         */

        baseFontList.add(BaseFont.createFont("MHei-Medium", "UniCNS-UCS2-H", BaseFont.EMBEDDED));
        baseFontList.add(BaseFont.createFont("MSung-Light", "UniCNS-UCS2-H", BaseFont.EMBEDDED));

        /**
         * Gets external chinese simplified BaseFonts
         * Recupera o BaseFont da fonte externa do Chins simplificado
         */
        baseFontList.add(BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.EMBEDDED));

        initFonts(baseFontList);
    } catch (DocumentException | IOException ex) {
        System.out.println("Error - BaseFont generation");
    }
}