Example usage for com.itextpdf.text Paragraph setAlignment

List of usage examples for com.itextpdf.text Paragraph setAlignment

Introduction

In this page you can find the example usage for com.itextpdf.text Paragraph setAlignment.

Prototype

public void setAlignment(int alignment) 

Source Link

Document

Sets the alignment of this paragraph.

Usage

From source file:lk.score.androphsy.report.ReportPdf.java

License:Open Source License

private void addDevicePage(Document document) {
    Anchor anchor = new Anchor("Device Information");
    anchor.setName("Device Information");
    Chapter chap = new Chapter(new Paragraph(anchor), 1);

    Paragraph subpara = new Paragraph("Device Information", HeadingFont);
    subpara.setAlignment(Paragraph.ALIGN_CENTER);
    addEmptyLine(subpara, 1);/*w w  w.ja va2s  . c  om*/
    createTableRowFormat(subpara, "DeviceBasicInfo");

    try {
        document.add(subpara);
    } catch (DocumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:lk.score.androphsy.report.ReportPdf.java

License:Open Source License

private void addContent(Document document, String feature) {
    String title = "";

    if (feature == "User Credentials") {
        title = "User Credentials";

    } else if (feature == "SMS") {
        title = "Short Message Service (SMS)";

    } else if (feature == "Phone Book") {
        title = "Contact Numbers/Phone Book";

    } else if (feature == "Gmail") {
        title = "Gmail Information";

    } else if (feature == "Calendar") {
        title = "Calendar Events";

    } else if (feature == "YouTube") {
        title = "YouTube History";

    } else if (feature.equals("FACEBOOK_MESSAGES")) {
        title = "Facebook Messages";

    } else if (feature.equals("FACEBOOK_CONTACTS")) {
        title = "Facebook Contacts";

    } else if (feature.equals("FACEBOOK_NOTIFICATIONS")) {
        title = "Facebook Notifications";

    } else if (feature.equals("LINKEDIN_PROFILE")) {
        title = "LinkedIn Profile";

    } else if (feature.equals("LINKEDIN_CONNECTIONS")) {
        title = "LinkedIn Connections";

    } else if (feature.equals("LINKEDIN_INVITATIONS")) {
        title = "LinkedIn Invitations";

    } else if (feature.equals("LINKEDIN_MESSAGES")) {
        title = "LinkedIn Messages";

    } else if (feature.equals("DEFAULT_WEB_FORM_DATA")) {
        title = "Interacted Web Forms and Supplied Parameter Values";

    } else if (feature.equals("DEFAULT_COOKIES")) {
        title = "Default Browser Cookie Information";

    } else if (feature.equals("DEFAULT_WEB_SEARCH")) {
        title = "Default Browser Web lk.score.androphsy.main.Search Text";

    } else if (feature.equals("DEFAULT_BOOKMARKS")) {
        title = "Bookmarked URL Information";

    } else if (feature.equals("DEFAULT_BROWSER_HISTORY")) {
        title = "Default Browser History";

    } else if (feature.equals("CHROME_BROWSER_HISTORY")) {
        title = "Chrome Browser History";

    } else if (feature.equals("CHROME_COOKIES")) {
        title = "Chrome Browser Cookie Information";

    } else if (feature.equals("CHROME_WEB_SEARCH")) {
        title = "Chrome Web lk.score.androphsy.main.Search Text";

    } else if (feature.equals("CHROME_CREDIT_CARD")) {
        title = "Chrome Credit Card Information";

    } else if (feature.equals("Firefox_COOKIES")) {
        title = "Firefox Browser Cookies";

    } else if (feature.equals("Firefox_WEB_SEARCH")) {
        title = "Firefox WebSearch";

    } else if (feature.equals("Firefox_BOOKMARKS")) {
        title = "Firefox Bookmark";

    } else if (feature.equals("Firefox_BROWSER_HISTORYy")) {
        title = "Firefox Browser History";

    } else if (feature.equals("Call Logs")) {
        title = "Call Logs";

    } else if (feature.equals("SMS Logs")) {
        title = "SMS Logs";

    } else if (feature.equals("MMS Logs")) {
        title = "MMS Logs";

    } else if (feature == "Wi-Fi Access Points") {
        title = "Wi-Fi Access Points";

    } else if (feature.equals("Wi-Fi Access Points")) {
        title = "Wi-Fi Access Points";

    } else if (feature == "Bluetooth Data") {
        title = "Bluetooth Information";

    } else if (feature.equals("Bluetooth Data")) {
        title = "Bluetooth Information";

    } else if (feature == "Skype Account") {
        title = "Skype Account";

    } else if (feature == "Skype Contacts") {
        title = "Skype Contacts";

    } else if (feature == "Skype Calls") {
        title = "Skype Call";

    } else if (feature == "Skype Messages") {
        title = "Skype Message";

    }//from  ww  w .  j av  a2  s . com

    try {
        document.newPage();

        Paragraph subpara = new Paragraph(title, HeadingFont);
        subpara.setAlignment(Paragraph.ALIGN_CENTER);
        addEmptyLine(subpara, 1);

        if (feature == "User Credentials") {
            Paragraph p1 = new Paragraph("Primary Account Detail", SubHeadingFont);
            addEmptyLine(p1, 1);
            CreateTable(p1, "PRIMARY_ACC");
            addEmptyLine(p1, 1);
            subpara.add(p1);

            Paragraph p2 = new Paragraph("Secondary Account Detail", SubHeadingFont);
            addEmptyLine(p2, 1);
            CreateTable(p2, "OTHER_ACC");
            subpara.add(p2);

        } else if (feature.equals("Call Logs")) {
            Paragraph p1 = new Paragraph("Incomming Calls Log", SubHeadingFont);
            addEmptyLine(p1, 1);
            CreateTable(p1, "INCOMING_CALLS");
            addEmptyLine(p1, 1);
            subpara.add(p1);

            Paragraph p2 = new Paragraph("Missed Calls Log", SubHeadingFont);
            addEmptyLine(p2, 1);
            CreateTable(p2, "MISSED_CALLS");
            subpara.add(p2);

            Paragraph p3 = new Paragraph("Cancelled Calls Log", SubHeadingFont);
            addEmptyLine(p3, 1);
            CreateTable(p3, "CANCELLED_CALLS");
            addEmptyLine(p3, 1);
            subpara.add(p3);

            Paragraph p4 = new Paragraph("Outgoing Calls Log", SubHeadingFont);
            addEmptyLine(p4, 1);
            CreateTable(p4, "OUTGOING_CALLS");
            subpara.add(p4);

        } else if (feature.equals("SMS Logs")) {
            Paragraph p1 = new Paragraph("Incomming SMS Log", SubHeadingFont);
            addEmptyLine(p1, 1);
            CreateTable(p1, "SMS_INBOX");
            addEmptyLine(p1, 1);
            subpara.add(p1);

            Paragraph p2 = new Paragraph("Outgoing SMS Log", SubHeadingFont);
            addEmptyLine(p2, 1);
            CreateTable(p2, "SMS_OUTBOX");
            subpara.add(p2);

        } else if (feature.equals("MMS Logs")) {

            Paragraph p1 = new Paragraph("Incomming MMS Log", SubHeadingFont);
            addEmptyLine(p1, 1);
            CreateTable(p1, "MMS_INBOX");
            addEmptyLine(p1, 1);
            subpara.add(p1);

            Paragraph p2 = new Paragraph("Outgoing MMS Log", SubHeadingFont);
            addEmptyLine(p2, 1);
            CreateTable(p2, "MMS_OUTBOX");
            subpara.add(p2);

        } else if (feature == "Bluetooth Data") {
            Paragraph p1 = new Paragraph("Nearby Bluetooth Device Information", SubHeadingFont);
            addEmptyLine(p1, 1);
            CreateTable(p1, "BT_SEEN");
            addEmptyLine(p1, 1);
            subpara.add(p1);

            Paragraph p2 = new Paragraph("Contacted Bluetooth Device Information", SubHeadingFont);
            addEmptyLine(p2, 1);
            CreateTable(p2, "BT_USED");
            subpara.add(p2);

        } else if (feature.equals("Bluetooth Data")) {
            Paragraph p1 = new Paragraph("Nearby Bluetooth Device Information", SubHeadingFont);
            addEmptyLine(p1, 1);
            CreateTable(p1, "BT_SEEN");
            addEmptyLine(p1, 1);
            subpara.add(p1);

            Paragraph p2 = new Paragraph("Contacted Bluetooth Device Information", SubHeadingFont);
            addEmptyLine(p2, 1);
            CreateTable(p2, "BT_USED");
            subpara.add(p2);
        } else {
            CreateTable(subpara, feature);
        }

        document.add(subpara);
    } catch (DocumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:lk.score.androphsy.report.ReportPdf.java

License:Open Source License

private void addTitlePage(Document document) {
    String creator_name = "";
    try {/*from  ww w . ja va  2s  .  co m*/
        Connection con = new ConnectDb().getConnection();
        Statement stmt = con.createStatement();
        ResultSet rs = stmt.executeQuery("SELECT first_name, last_name FROM Androspy_User WHERE user_name = '"
                + AndrospyMain.gb_username + "'");
        while (rs.next()) {
            creator_name = rs.getString("first_name") + " " + rs.getString("last_name");
        }
    } catch (SQLException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    Paragraph preface = new Paragraph();
    addEmptyLine(preface, 1);

    Paragraph title = new Paragraph("ANDROSPY SOFTWARE", TitleFont);
    addEmptyLine(title, 1);
    title.add(new Paragraph("Report Genereated By: " + creator_name));
    title.add(new Paragraph("Date: " + gen_date));
    title.setAlignment(Paragraph.ALIGN_CENTER);

    preface.add(title);
    addEmptyLine(preface, 2);

    preface.add(new Paragraph("Case Basic Detail:"));
    addEmptyLine(preface, 1);

    createTableRowFormat(preface, "CaseInfo");

    try {
        document.add(preface);
    } catch (DocumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    document.newPage();
}

From source file:Logic.DocsCreation.java

public void createPdfDoc(JTable Table, GetPatientData data, StartDB con, boolean flag,
        ArrayList<String> arrPatient, String crb) {
    try {//w w w . j  ava 2s . c  o  m
        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:logica.Generar_pdf.java

public void ConvertirPDF(int num, String nombre, String nombre2, String cedula, String cedula2,
        String direccion, String direccion2, String telefono, String telefono2, String sede, String tipo,
        String observacion, int peso, int declaracion_precio, int precio_neto, int precio_seguro,
        int precio_impuesto, int total_envio, String forma_pago, String fecha) throws FileNotFoundException {
    String nombre_pdf = "Factura No " + num + ".pdf";
    System.out.println(nombre_pdf);
    try {//from w  w w  . ja  v a2 s . c  o m
        //Creamos documento indicando el tamao y margenes
        Document documento = new Document(PageSize.LETTER, 20, 20, 20, 20);

        //Creamos el PDF y lo instanceamos para poder escribir sobre el
        PdfWriter.getInstance(documento, new FileOutputStream(nombre_pdf)).setInitialLeading(20);

        //Abrimos el documento
        documento.open();
        System.out.println("Documento Abierto");

        //Anexamos el texto a un objeto Pharagraph
        Paragraph parametro = new Paragraph("Factura Envio de Paquete No. " + num,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 14, Font.BOLD, BaseColor.BLACK));
        parametro.setAlignment(1);
        Paragraph parametro17 = new Paragraph("Fecha: " + fecha,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 14, Font.BOLD, BaseColor.BLACK));
        parametro17.setAlignment(1);
        Paragraph parametro2 = new Paragraph("Datos Remitente",
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.BOLD, BaseColor.BLACK));
        Paragraph parametro3 = new Paragraph("Nombre: " + nombre + "        Telefono: " + telefono,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK));
        Paragraph parametro4 = new Paragraph("Cedula: " + cedula + "        Direccin: " + direccion,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK));
        Paragraph parametro5 = new Paragraph("Datos Destinatario",
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.BOLD, BaseColor.BLACK));
        Paragraph parametro6 = new Paragraph("Nombre: " + nombre2 + "        Telefono: " + telefono2,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK));
        Paragraph parametro7 = new Paragraph("Cedula: " + cedula2 + "        Direccin: " + direccion2,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK));

        Paragraph parametro8 = new Paragraph("Datos Envio",
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.BOLD, BaseColor.BLACK));
        Paragraph parametro9 = new Paragraph("Tipo de Envio: " + tipo + "        Observacin: " + observacion,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK));
        Paragraph parametro10 = new Paragraph(
                "Peso: " + peso + "        Declaracin precio Envio: " + declaracion_precio,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK));
        Paragraph parametro11 = new Paragraph("Datos Pago",
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.BOLD, BaseColor.BLACK));
        Paragraph parametro12 = new Paragraph("Precio de Envio Neto: " + precio_neto,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK));
        Paragraph parametro13 = new Paragraph("Precio Seguro:  " + precio_seguro,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK));
        Paragraph parametro14 = new Paragraph("Excedente Impuesto:  " + precio_impuesto,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK));
        Paragraph parametro15 = new Paragraph("Total Envio:  " + total_envio,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK));
        Paragraph parametro16 = new Paragraph("Forma de Pago:  " + forma_pago,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK));

        //Escribimos sobre el
        documento.add(parametro);
        documento.add(parametro17);
        documento.add(parametro2);
        documento.add(parametro3);
        documento.add(parametro4);
        documento.add(parametro5);
        documento.add(parametro6);
        documento.add(parametro7);
        documento.add(parametro8);
        documento.add(parametro9);
        documento.add(parametro10);
        documento.add(parametro11);
        documento.add(parametro12);
        documento.add(parametro13);
        documento.add(parametro14);
        documento.add(parametro15);
        documento.add(parametro16);

        //Cerrar documento
        documento.close();

        //Mensaje de Exito
        JOptionPane.showMessageDialog(null, "PDF Creado con exito.");

    } catch (DocumentException de) {
        System.out.println("Error...");
    }

}

From source file:main.ItextPDF.java

public void createPdf(String filename, Person person) {
    // step 1//  w  w w. jav  a2 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:managedbeans.Doctor.ImprimirAnamnesis.java

/**
 * Handles the HTTP <code>GET</code> method.
 *
 * @param request servlet request//  w w w  .ja va  2 s .c  o m
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("application/pdf");
    String rut = request.getParameter("rut");
    String id = request.getParameter("id");
    Integer search = Integer.parseInt(rut);
    Integer idEp = Integer.parseInt(id);
    episodio = episodiosFacade.find(idEp);
    List<Persona> person = personaNegocio.busquedaPersonaRut(search);
    Persona personSelected;

    if (person.size() > 0) {
        System.out.println("La cantidad es:" + person.size());
        personSelected = person.get(0);
        System.out.println("La cantidad es:" + personSelected.getPersNombres());
        paciente = pacienteNegocio.busquedaPacienteIdPersona(personSelected.getIdPersona());
        signos = muestaFacade.searchByPatient(paciente);
        if (signos.size() > 0) {
            for (Muesta signo : signos) {
                if (signo.getIdSvitales().getIdSvitales() == 1)
                    peso = signo.getValor();
                if (signo.getIdSvitales().getIdSvitales() == 2)
                    altura = signo.getValor();
                if (signo.getIdSvitales().getIdSvitales() == 3)
                    temperatura = signo.getValor();
                if (signo.getIdSvitales().getIdSvitales() == 5)
                    presion = signo.getValor();
                if (signo.getIdSvitales().getIdSvitales() == 9)
                    pulso = signo.getValor();
                if (signo.getIdSvitales().getIdSvitales() == 17)
                    imc = signo.getValor();
            }
        }
        if (consultaFacade.searchByEpisodio(episodio).size() > 0)
            consulta = consultaFacade.searchByEpisodio(episodio).get(0);
        patientName = personSelected.getPersNombres() + " " + personSelected.getPersApepaterno() + " "
                + personSelected.getPersApematerno();
        patientRut = search;
        patientFonasa = "";
        patientIsapre = paciente.getPaciOtraprevision();
        home = personSelected.getPersDireccion();
        commune = paciente.getPersona().getIdComuna().getComuNombre();
        region = "";
        phoneNumber = personSelected.getPersTelefono();
        celularNumber = personSelected.getPersCelular();
        mail = personSelected.getPersEmail();
    }
    try {
        //style
        Font typeBold = new Font(Font.FontFamily.TIMES_ROMAN, 12, 1);
        Font type = new Font(Font.FontFamily.TIMES_ROMAN, 10);
        Font title = new Font(Font.FontFamily.TIMES_ROMAN, 15, 1);
        Font subTitle = new Font(Font.FontFamily.TIMES_ROMAN, 13, 1);
        Font subTitle2 = new Font(Font.FontFamily.TIMES_ROMAN, 10, 1);
        float space = (float) 20;

        Document document = new Document();
        document.setPageSize(PageSize.LETTER);
        PdfWriter.getInstance(document, response.getOutputStream());
        document.open();

        //General
        PdfPTable table;
        Paragraph p1;
        Paragraph p2;
        PdfPCell cellRow1;
        PdfPCell cellRow2;

        //row: 1
        table = new PdfPTable(2);
        table.setWidthPercentage(100);
        p1 = new Paragraph(space, "ANAMNESIS", title);
        p1.setAlignment(Element.ALIGN_CENTER);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        table.addCell(cellRow1);
        p1 = new Paragraph(space, "Hospital Barros Luco", subTitle2);
        p1.setAlignment(Element.ALIGN_CENTER);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        table.addCell(cellRow1);
        document.add(table);
        document.add(new Paragraph("\n"));

        //row 3
        table = new PdfPTable(2);
        table.setWidthPercentage(100);
        p1 = new Paragraph(space, "ANTECEDENTES DEL PACIENTE", subTitle);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthTop(1);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        p1 = new Paragraph(space, "NOMBRE: " + patientName, type);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        table.addCell(cellRow1);
        p1 = new Paragraph(space, "RUT: " + patientRut, type);
        p2 = new Paragraph(space, "PREVISION: " + paciente.getIdPrevision().getPreviNombre(), type);
        cellRow1 = new PdfPCell(p1);
        cellRow2 = new PdfPCell(p2);
        formatCellBorder(cellRow1, 20);
        formatCellBorder(cellRow2, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow2.setBorderWidthRight(1);
        table.addCell(cellRow1);
        table.addCell(cellRow2);
        p1 = new Paragraph(space, "COMUNA: " + commune, type);
        p2 = new Paragraph(space, "DOMICILIO: " + home, type);
        cellRow1 = new PdfPCell(p1);
        cellRow2 = new PdfPCell(p2);
        formatCellBorder(cellRow1, 20);
        formatCellBorder(cellRow2, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow2.setBorderWidthRight(1);
        table.addCell(cellRow1);
        table.addCell(cellRow2);
        p1 = new Paragraph(space, "TELFONO DE CONTACTO: " + paciente.getPersona().getPersTelcontacto(), type);
        p2 = new Paragraph(space, "CORREO: " + paciente.getPersona().getPersEmail(), type);
        cellRow1 = new PdfPCell(p1);
        cellRow2 = new PdfPCell(p2);
        formatCellBorder(cellRow1, 20);
        formatCellBorder(cellRow2, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow2.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        cellRow2.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        table.addCell(cellRow2);
        document.add(table);
        document.add(new Paragraph("\n"));

        //row 4
        table = new PdfPTable(2);
        table.setWidthPercentage(100);
        p1 = new Paragraph(space, "ANAMNESIS", subTitle);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthTop(1);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        p1 = new Paragraph(space, consulta.getMotivoConsulta(), type);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        document.add(table);
        document.add(new Paragraph("\n"));

        table = new PdfPTable(2);
        table.setWidthPercentage(100);
        p1 = new Paragraph(space, "HISTORIA OBSTTRICA", subTitle);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthTop(1);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        p1 = new Paragraph(space, "F.U.R.: ", type);
        p2 = new Paragraph(space, "F.P.P.: ", type);
        cellRow1 = new PdfPCell(p1);
        cellRow2 = new PdfPCell(p2);
        formatCellBorder(cellRow1, 20);
        formatCellBorder(cellRow2, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow2.setBorderWidthRight(1);
        table.addCell(cellRow1);
        table.addCell(cellRow2);
        p1 = new Paragraph(space, "PARTOS: ", type);
        p2 = new Paragraph(space, "ABORTOS: ", type);
        cellRow1 = new PdfPCell(p1);
        cellRow2 = new PdfPCell(p2);
        formatCellBorder(cellRow1, 20);
        formatCellBorder(cellRow2, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow2.setBorderWidthRight(1);
        table.addCell(cellRow1);
        table.addCell(cellRow2);
        p1 = new Paragraph(space, "FECHA LTIMO PARTO: ", type);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        document.add(table);
        document.add(new Paragraph("\n"));

        table = new PdfPTable(2);
        table.setWidthPercentage(100);
        p1 = new Paragraph(space, "EX?MEN F?SICO", subTitle);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthTop(1);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        p1 = new Paragraph(space, "PRESIN ARTERIAL: " + presion, type);
        p2 = new Paragraph(space, "TEMPERATURA: " + temperatura, type);
        cellRow1 = new PdfPCell(p1);
        cellRow2 = new PdfPCell(p2);
        formatCellBorder(cellRow1, 20);
        formatCellBorder(cellRow2, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow2.setBorderWidthRight(1);
        table.addCell(cellRow1);
        table.addCell(cellRow2);
        p1 = new Paragraph(space, "PULSO: " + pulso, type);
        p2 = new Paragraph(space, "PESO: " + peso, type);
        cellRow1 = new PdfPCell(p1);
        cellRow2 = new PdfPCell(p2);
        formatCellBorder(cellRow1, 20);
        formatCellBorder(cellRow2, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow2.setBorderWidthRight(1);
        table.addCell(cellRow1);
        table.addCell(cellRow2);
        p1 = new Paragraph(space, "TALLA: " + altura, type);
        p2 = new Paragraph(space, "I.M.C.: " + imc, type);
        cellRow1 = new PdfPCell(p1);
        cellRow2 = new PdfPCell(p2);
        formatCellBorder(cellRow1, 20);
        formatCellBorder(cellRow2, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow2.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        cellRow2.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        table.addCell(cellRow2);
        document.add(table);
        document.add(new Paragraph("\n"));

        table = new PdfPTable(2);
        table.setWidthPercentage(100);
        p1 = new Paragraph(space, "EX?MEN OBSTTRICO", subTitle);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthTop(1);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        p1 = new Paragraph(space, "A.U.: ", type);
        p2 = new Paragraph(space, "L.C.F.: ", type);
        cellRow1 = new PdfPCell(p1);
        cellRow2 = new PdfPCell(p2);
        formatCellBorder(cellRow1, 20);
        formatCellBorder(cellRow2, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow2.setBorderWidthRight(1);
        table.addCell(cellRow1);
        table.addCell(cellRow2);
        p1 = new Paragraph(space, "D.U.: ", type);
        p2 = new Paragraph(space, "PRESENTACIN: ", type);
        cellRow1 = new PdfPCell(p1);
        cellRow2 = new PdfPCell(p2);
        formatCellBorder(cellRow1, 20);
        formatCellBorder(cellRow2, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow2.setBorderWidthRight(1);
        if (1 == 0) {
            table.addCell(cellRow1);
            table.addCell(cellRow2);
            p1 = new Paragraph(space, "POSICIN: ", type);
            p2 = new Paragraph(space, "CONSISTENCIA: ", type);
            cellRow1 = new PdfPCell(p1);
            cellRow2 = new PdfPCell(p2);
            formatCellBorder(cellRow1, 20);
            formatCellBorder(cellRow2, 20);
            cellRow1.setBorderWidthLeft(1);
            cellRow2.setBorderWidthRight(1);
            table.addCell(cellRow1);
            table.addCell(cellRow2);
            p1 = new Paragraph(space, "BORRAMIENTO: ", type);
            p2 = new Paragraph(space, "DILATACION: ", type);
            cellRow1 = new PdfPCell(p1);
            cellRow2 = new PdfPCell(p2);
            formatCellBorder(cellRow1, 20);
            formatCellBorder(cellRow2, 20);
            cellRow1.setBorderWidthLeft(1);
            cellRow2.setBorderWidthRight(1);
            table.addCell(cellRow1);
            table.addCell(cellRow2);
            p1 = new Paragraph(space, "PLANO: ", type);
            p2 = new Paragraph(space, "MEMBRANAS: ", type);
            cellRow1 = new PdfPCell(p1);
            cellRow2 = new PdfPCell(p2);
            formatCellBorder(cellRow1, 20);
            formatCellBorder(cellRow2, 20);
            cellRow1.setBorderWidthLeft(1);
            cellRow2.setBorderWidthRight(1);
        }
        cellRow1.setBorderWidthBottom(1);
        cellRow2.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        table.addCell(cellRow2);
        document.add(table);
        document.add(new Paragraph("\n"));

        table = new PdfPTable(2);
        table.setWidthPercentage(100);
        p1 = new Paragraph(space, "RESUMEN PATOLOG?AS MATERNAS", subTitle);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthTop(1);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        p1 = new Paragraph(space, "PATOLOG?AS: ", type);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        document.add(table);
        document.add(new Paragraph("\n"));

        table = new PdfPTable(2);
        table.setWidthPercentage(100);
        p1 = new Paragraph(space, "DIAGNOSTICOS", subTitle);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthTop(1);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        p1 = new Paragraph(space, "Este es un diagnostico", type);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        document.add(table);
        document.add(new Paragraph("\n"));

        table = new PdfPTable(2);
        table.setWidthPercentage(100);
        p1 = new Paragraph(space, "INDICACIONES", subTitle);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthTop(1);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        p1 = new Paragraph(space, "Estas son indicaciones", type);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        document.add(table);

        document.close();
    } catch (DocumentException de) {
        throw new IOException(de.getMessage());
    }

}

From source file:managedbeans.ImprimirAnamnesis.java

/**
 * Handles the HTTP <code>GET</code> method.
 *
 * @param request servlet request/*  w ww  .ja  v a 2  s. c  o m*/
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("application/pdf");
    String rut = request.getParameter("rut");
    String idAnam = request.getParameter("id");
    Integer search = Integer.parseInt(rut);
    Integer anam = Integer.parseInt(idAnam);
    anamnesis = anamnesisFacade.find(anam);
    List<Persona> person = personaNegocio.busquedaPersonaRut(search);
    Persona personSelected;

    if (person.size() > 0) {
        System.out.println("La cantidad es:" + person.size());
        personSelected = person.get(0);
        System.out.println("La cantidad es:" + personSelected.getPersNombres());
        paciente = pacienteNegocio.busquedaPacienteIdPersona(personSelected.getIdPersona());
        patientName = personSelected.getPersNombres() + " " + personSelected.getPersApepaterno() + " "
                + personSelected.getPersApematerno();
        patientRut = search;
        patientFonasa = "";
        patientIsapre = paciente.getPaciOtraprevision();
        home = personSelected.getPersDireccion();
        commune = "";
        region = "";
        phoneNumber = personSelected.getPersTelefono();
        celularNumber = personSelected.getPersCelular();
        mail = personSelected.getPersEmail();
    }
    try {
        //style
        Font typeBold = new Font(Font.FontFamily.TIMES_ROMAN, 12, 1);
        Font type = new Font(Font.FontFamily.TIMES_ROMAN, 10);
        Font title = new Font(Font.FontFamily.TIMES_ROMAN, 15, 1);
        Font subTitle = new Font(Font.FontFamily.TIMES_ROMAN, 13, 1);
        Font subTitle2 = new Font(Font.FontFamily.TIMES_ROMAN, 10, 1);
        float space = (float) 20;

        Document document = new Document();
        document.setPageSize(PageSize.LETTER);
        PdfWriter.getInstance(document, response.getOutputStream());
        document.open();

        //General
        PdfPTable table;
        Paragraph p1;
        Paragraph p2;
        PdfPCell cellRow1;
        PdfPCell cellRow2;

        //row: 1
        table = new PdfPTable(2);
        table.setWidthPercentage(100);
        p1 = new Paragraph(space, "ANAMNESIS", title);
        p1.setAlignment(Element.ALIGN_CENTER);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        table.addCell(cellRow1);
        p1 = new Paragraph(space, "Hospital Barros Luco", subTitle2);
        p1.setAlignment(Element.ALIGN_CENTER);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        table.addCell(cellRow1);
        document.add(table);
        document.add(new Paragraph("\n"));

        //row 3
        table = new PdfPTable(2);
        table.setWidthPercentage(100);
        p1 = new Paragraph(space, "ANTECEDENTES DEL PACIENTE", subTitle);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthTop(1);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        p1 = new Paragraph(space, "NOMBRE: " + patientName, type);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        table.addCell(cellRow1);
        p1 = new Paragraph(space, "RUT: " + patientRut, type);
        p2 = new Paragraph(space, "FONASA: " + patientFonasa, type);
        cellRow1 = new PdfPCell(p1);
        cellRow2 = new PdfPCell(p2);
        formatCellBorder(cellRow1, 20);
        formatCellBorder(cellRow2, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow2.setBorderWidthRight(1);
        table.addCell(cellRow1);
        table.addCell(cellRow2);
        p1 = new Paragraph(space, "ISAPRE: " + patientIsapre, type);
        p2 = new Paragraph(space, "DOMICILIO: " + home, type);
        cellRow1 = new PdfPCell(p1);
        cellRow2 = new PdfPCell(p2);
        formatCellBorder(cellRow1, 20);
        formatCellBorder(cellRow2, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow2.setBorderWidthRight(1);
        table.addCell(cellRow1);
        table.addCell(cellRow2);
        p1 = new Paragraph(space, "COMUNA: " + commune, type);
        p2 = new Paragraph(space, "REGION: " + region, type);
        cellRow1 = new PdfPCell(p1);
        cellRow2 = new PdfPCell(p2);
        formatCellBorder(cellRow1, 20);
        formatCellBorder(cellRow2, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow2.setBorderWidthRight(1);
        table.addCell(cellRow1);
        table.addCell(cellRow2);
        p1 = new Paragraph(space, "N TELFONO FIJO: " + phoneNumber, type);
        p2 = new Paragraph(space, "N TELFONO CELULAR: " + celularNumber, type);
        cellRow1 = new PdfPCell(p1);
        cellRow2 = new PdfPCell(p2);
        formatCellBorder(cellRow1, 20);
        formatCellBorder(cellRow2, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow2.setBorderWidthRight(1);
        table.addCell(cellRow1);
        table.addCell(cellRow2);
        p1 = new Paragraph(space, "DIRECCIN CORREO ELECTRNICO (E-MAIL): " + mail, type);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);

        table.addCell(cellRow1);
        document.add(table);
        document.add(new Paragraph("\n"));

        //row 4
        table = new PdfPTable(2);
        table.setWidthPercentage(100);
        p1 = new Paragraph(space, "ANAMNESIS", subTitle);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthTop(1);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        p1 = new Paragraph(space, anamnesis.getAnamDescripcion(), type);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        document.add(table);
        document.add(new Paragraph("\n"));

        table = new PdfPTable(2);
        table.setWidthPercentage(100);
        p1 = new Paragraph(space, "HISTORIA OBSTTRICA", subTitle);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthTop(1);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        p1 = new Paragraph(space, anamnesis.getAnamDescripcion(), type);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        document.add(table);
        document.add(new Paragraph("\n"));

        table = new PdfPTable(2);
        table.setWidthPercentage(100);
        p1 = new Paragraph(space, "EX?MEN F?SICO", subTitle);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthTop(1);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        p1 = new Paragraph(space, anamnesis.getAnamDescripcion(), type);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        document.add(table);
        document.add(new Paragraph("\n"));

        table = new PdfPTable(2);
        table.setWidthPercentage(100);
        p1 = new Paragraph(space, "EX?MEN OBSTTRICO", subTitle);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthTop(1);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        p1 = new Paragraph(space, anamnesis.getAnamDescripcion(), type);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        document.add(table);
        document.add(new Paragraph("\n"));

        table = new PdfPTable(2);
        table.setWidthPercentage(100);
        p1 = new Paragraph(space, "RESUMEN PATOLOG?AS MATERNAS", subTitle);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthTop(1);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        p1 = new Paragraph(space, anamnesis.getAnamDescripcion(), type);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        document.add(table);
        document.add(new Paragraph("\n"));

        table = new PdfPTable(2);
        table.setWidthPercentage(100);
        p1 = new Paragraph(space, "DIAGNOSTICOS", subTitle);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthTop(1);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        p1 = new Paragraph(space, anamnesis.getAnamDescripcion(), type);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        document.add(table);
        document.add(new Paragraph("\n"));

        table = new PdfPTable(2);
        table.setWidthPercentage(100);
        p1 = new Paragraph(space, "INDICACIONES", subTitle);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthTop(1);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        p1 = new Paragraph(space, anamnesis.getAnamDescripcion(), type);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        document.add(table);

        document.close();
    } catch (DocumentException de) {
        throw new IOException(de.getMessage());
    }

}

From source file:managedbeanTest.PruebaMartolo.java

@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("application/pdf");

    try {/*from  www.  ja v  a 2 s.c o m*/
        //style
        Font typeBold = new Font(Font.FontFamily.TIMES_ROMAN, 12, 1);
        Font type = new Font(Font.FontFamily.TIMES_ROMAN, 10);
        Font title = new Font(Font.FontFamily.TIMES_ROMAN, 15, 1);
        Font subTitle = new Font(Font.FontFamily.TIMES_ROMAN, 13, 1);
        Font subTitle2 = new Font(Font.FontFamily.TIMES_ROMAN, 10, 1);
        float space = (float) 20;

        Document document = new Document();
        document.setPageSize(PageSize.LETTER);
        PdfWriter.getInstance(document, response.getOutputStream());
        document.open();

        //General
        PdfPTable table;
        Paragraph p1;
        Paragraph p2;
        PdfPCell cellRow1;
        PdfPCell cellRow2;

        //row: 1
        table = new PdfPTable(2);
        table.setWidthPercentage(100);
        p1 = new Paragraph(space, "FORMULARIO DE CONSTANCIA DE INFORMACION AL PACIENTE GES", title);
        p1.setAlignment(Element.ALIGN_CENTER);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        table.addCell(cellRow1);
        p1 = new Paragraph(space, "(Artculo 24, Ley 19.966)", subTitle2);
        p1.setAlignment(Element.ALIGN_CENTER);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        table.addCell(cellRow1);
        document.add(table);
        document.add(new Paragraph("\n"));

        //row: 2
        table = new PdfPTable(2);
        table.setWidthPercentage(100);
        p1 = new Paragraph(space, "DATOS DEL PRESTADOR", subTitle);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthTop(1);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        p1 = new Paragraph(space, "INSTITUCIN (Hospital, Clnica, Consultorio,etc): " + institution, type);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        table.addCell(cellRow1);
        p1 = new Paragraph(space, "DIRECCION: " + address, type);
        p2 = new Paragraph(space, "CIUDAD: " + city, type);
        cellRow1 = new PdfPCell(p1);
        cellRow2 = new PdfPCell(p2);
        formatCellBorder(cellRow1, 20);
        formatCellBorder(cellRow2, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow2.setBorderWidthRight(1);
        table.addCell(cellRow1);
        table.addCell(cellRow2);
        p1 = new Paragraph(space, "NOMBRE PERSONA QUE NOTIFICA: " + personName, type);
        p2 = new Paragraph(space, "RUT: " + rut, type);
        cellRow1 = new PdfPCell(p1);
        cellRow2 = new PdfPCell(p2);
        formatCellBorder(cellRow1, 20);
        formatCellBorder(cellRow2, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow2.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        cellRow2.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        table.addCell(cellRow2);
        document.add(table);
        document.add(new Paragraph("\n"));

        //row 3
        table = new PdfPTable(2);
        table.setWidthPercentage(100);
        p1 = new Paragraph(space, "ANTECEDENTES DEL PACIENTE", subTitle);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthTop(1);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        p1 = new Paragraph(space, "NOMBRE: " + patientName, type);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        table.addCell(cellRow1);
        p1 = new Paragraph(space, "RUT: " + patientRut, type);
        p2 = new Paragraph(space, "FONASA: " + patientFonasa, type);
        cellRow1 = new PdfPCell(p1);
        cellRow2 = new PdfPCell(p2);
        formatCellBorder(cellRow1, 20);
        formatCellBorder(cellRow2, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow2.setBorderWidthRight(1);
        table.addCell(cellRow1);
        table.addCell(cellRow2);
        p1 = new Paragraph(space, "ISAPRE: " + patientIsapre, type);
        p2 = new Paragraph(space, "DOMICILIO: " + home, type);
        cellRow1 = new PdfPCell(p1);
        cellRow2 = new PdfPCell(p2);
        formatCellBorder(cellRow1, 20);
        formatCellBorder(cellRow2, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow2.setBorderWidthRight(1);
        table.addCell(cellRow1);
        table.addCell(cellRow2);
        p1 = new Paragraph(space, "COMUNA: " + commune, type);
        p2 = new Paragraph(space, "REGION: " + region, type);
        cellRow1 = new PdfPCell(p1);
        cellRow2 = new PdfPCell(p2);
        formatCellBorder(cellRow1, 20);
        formatCellBorder(cellRow2, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow2.setBorderWidthRight(1);
        table.addCell(cellRow1);
        table.addCell(cellRow2);
        p1 = new Paragraph(space, "N TELFONO FIJO: " + phoneNumber, type);
        p2 = new Paragraph(space, "N TELFONO CELULAR: " + celularNumber, type);
        cellRow1 = new PdfPCell(p1);
        cellRow2 = new PdfPCell(p2);
        formatCellBorder(cellRow1, 20);
        formatCellBorder(cellRow2, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow2.setBorderWidthRight(1);
        table.addCell(cellRow1);
        table.addCell(cellRow2);
        p1 = new Paragraph(space, "DIRECCIN CORREO ELECTRNICO (E-MAIL): " + mail, type);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);

        table.addCell(cellRow1);
        document.add(table);
        document.add(new Paragraph("\n"));

        //row 4
        table = new PdfPTable(2);
        table.setWidthPercentage(100);
        p1 = new Paragraph(space, "INFORMACIN MDICA", subTitle);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthTop(1);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        p1 = new Paragraph(space, "CONFIRMACIN DIAGNSTICA GES:", type);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        table.addCell(cellRow1);
        p1 = new Paragraph(space, ges, type);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        table.addCell(cellRow1);
        p1 = new Paragraph(space, "(  ) Confirmacin Diagnstica", type);
        p2 = new Paragraph(space, "(  ) Paciente en Tratamiento", type);
        cellRow1 = new PdfPCell(p1);
        cellRow2 = new PdfPCell(p2);
        formatCellBorder(cellRow1, 20);
        formatCellBorder(cellRow2, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow2.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        cellRow2.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        table.addCell(cellRow2);
        document.add(table);
        //row 5
        document.add(new Paragraph(space, "CONSTANCIA", subTitle));
        Paragraph text1 = new Paragraph(space,
                "Declaro que, con esta fecha y hora, he tomado conocimiento que tengo derecho a acceder a las Garantas Explcitas en Salud, siempre que la atencin sea otorgada en la red de Prestadores que me corresponde segn Fonasa o Isapre, a la que me encuentro adscrito",
                type);
        text1.setAlignment(Element.ALIGN_JUSTIFIED);
        document.add(text1);
        document.add(new Paragraph(space, "IMPORTANTE", subTitle));
        Paragraph text2 = new Paragraph(space,
                "Tenga presente que s no se cumplen las garantas usted puede reclamar ante Fonasa o la Isapre, segn corresponda. Si la respuesta no es satisfactoria, usted puede recurrir en segunda instancia a la Superintendencia de Salud.",
                type);
        text2.setAlignment(Element.ALIGN_JUSTIFIED);
        document.add(text2);
        document.add(new Paragraph(space, "FECHA Y HORA DE NOTIFICACIN: " + "-", subTitle));
        document.add(new Paragraph(space, "\n", type));
        document.add(new Paragraph(space, "\n", type));
        document.add(new Paragraph(space, "\n", type));
        //row 6
        table = new PdfPTable(2);
        table.setWidthPercentage(100);
        p1 = new Paragraph(space, "INFORM DIAGNSTICO GES", subTitle);
        p2 = new Paragraph(space, "TOM CONOCIMIENTO", subTitle);
        cellRow1 = new PdfPCell(p1);
        cellRow2 = new PdfPCell(p2);
        formatCellBorder(cellRow1, 20);
        formatCellBorder(cellRow2, 20);
        table.addCell(cellRow1);
        table.addCell(cellRow2);
        p1 = new Paragraph(space, "(Firma de persona que notifica)", subTitle2);
        p2 = new Paragraph(space, "(Firma o huella digital  representante)", subTitle2);
        cellRow1 = new PdfPCell(p1);
        cellRow2 = new PdfPCell(p2);
        formatCellBorder(cellRow1, 20);
        formatCellBorder(cellRow2, 20);
        table.addCell(cellRow1);
        table.addCell(cellRow2);
        document.add(table);
        //row 7
        document.add(new Paragraph(space,
                "En caso que la persona que tom conocimiento no sea el paciente, identificar.", type));

        //row 8
        table = new PdfPTable(2);
        table.setWidthPercentage(100);
        p1 = new Paragraph(space, "Nombre:", type);
        p2 = new Paragraph(space, "R.U.T:", type);
        cellRow1 = new PdfPCell(p1);
        cellRow2 = new PdfPCell(p2);
        formatCellBorder(cellRow1, 20);
        formatCellBorder(cellRow2, 20);
        table.addCell(cellRow1);
        table.addCell(cellRow2);
        p1 = new Paragraph(space, "N Telfono Celular:", type);
        p2 = new Paragraph(space, "Direccin correo electrnico (e-mail):", type);
        cellRow1 = new PdfPCell(p1);
        cellRow2 = new PdfPCell(p2);
        formatCellBorder(cellRow1, 20);
        formatCellBorder(cellRow2, 20);
        table.addCell(cellRow1);
        table.addCell(cellRow2);
        document.add(table);

        document.close();
    } catch (DocumentException de) {
        throw new IOException(de.getMessage());
    }

}

From source file:Measurment_Result_Record.MeasurmentSetup.java

private void jMenuItem_exportpdfActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_exportpdfActionPerformed
    // TODO add your handling code here:
    // TODO add your handling code here:
    try {//from   w w  w.j  a v  a 2 s .c o  m
        // TODO add your handling code here:
        JFileChooser fchooser = new JFileChooser();
        int status = fchooser.showSaveDialog(null);
        if (status != JFileChooser.APPROVE_OPTION)
            return;
        fchooser.setDialogTitle("Save the Measurment result to pdf.");
        File selectedF = fchooser.getSelectedFile();
        String filename = selectedF.getAbsolutePath();
        //get the file path to save the pdf
        Document document = new Document();
        PdfWriter.getInstance(document, new FileOutputStream(filename + ".pdf"));
        document.open();
        //add the IPELS logo and title
        int size = 30;
        com.itextpdf.text.Font titleFont;
        titleFont = FontFactory.getFont(FontFactory.TIMES_BOLD, size, com.itextpdf.text.Font.BOLD,
                BaseColor.BLUE);
        Paragraph ipels = new Paragraph("IPELS", titleFont);
        ipels.setAlignment(Element.ALIGN_CENTER);

        document.add(ipels);
        titleFont.setSize(25);
        Paragraph para = new Paragraph("Measurment result \n ", titleFont);
        para.setAlignment(Element.ALIGN_CENTER);
        document.add(para);

        //loop through all the measurmentsetups tables and add each of them to the document
        for (MeasurmentSetup mesSetup : this.presenter.allMeasurmentSetups) {
            addResultTablesTotheDocument(document, mesSetup.recordTablePreview, mesSetup.getMeasurmentTitle());
        }

        //close the document
        document.close();
        //preview the document
        Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + filename + ".pdf");
    } catch (FileNotFoundException ex) {
        JOptionPane.showMessageDialog(null, ex.getMessage(), "Save to pdf", JOptionPane.ERROR_MESSAGE);
    } catch (DocumentException ex) {
        JOptionPane.showMessageDialog(null, ex.getMessage(), "Save to pdf", JOptionPane.ERROR_MESSAGE);
    } catch (IOException ex) {
        JOptionPane.showMessageDialog(null, ex.getMessage(), "opening pdf", JOptionPane.ERROR_MESSAGE);
    }
}