Example usage for com.itextpdf.text.pdf PdfPTable setWidthPercentage

List of usage examples for com.itextpdf.text.pdf PdfPTable setWidthPercentage

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfPTable setWidthPercentage.

Prototype

public void setWidthPercentage(final float widthPercentage) 

Source Link

Document

Sets the width percentage that the table will occupy in the page.

Usage

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

License:Open Source License

private void CreateTable(Paragraph subpara, String feature) {
    System.out.println("Report Create Table: " + feature);
    try {// w  w w .  j  av a  2 s . c  o m
        String query = "";
        Connection conn = new ConnectDb().getConnection();
        Statement stmt = conn.createStatement();

        if (feature == "PRIMARY_ACC") {
            query = "SELECT host AS 'Account Type', username AS 'User Name',"
                    + " password AS 'Password (HASHED)'" + " FROM Androspy_Account" + " WHERE case_id = "
                    + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId
                    + " AND primary_acc = " + 1;

        } else if (feature == "OTHER_ACC") {
            query = "SELECT host AS 'Account Type', username AS 'User Name'," + " password AS 'Password'"
                    + " FROM Androspy_Account" + " WHERE case_id = " + AndrospyMain.gb_CaseId
                    + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND primary_acc != " + 1;

        } else if (feature == "SMS") {
            query = "SELECT subject AS 'Subject', body AS 'Message Body',"
                    + " type AS 'Message Type', date_received AS 'Received Date', date_sent AS 'Send Date'"
                    + " FROM Sms" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId;

        } else if (feature == "Phone Book") {
            query = "SELECT contact_no AS 'Contact No', name AS 'Name',"
                    + " times_contacted AS 'Times Contacted', last_time_contacted AS 'Last Contacted Date'"
                    + " FROM Contacts" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId;

        } else if (feature == "Gmail") {
            query = "SELECT fromaddress AS 'From Address',"
                    + " toaddress AS 'To Address', ccaddress AS 'CC Address', bccaddress AS 'BCC Address',"
                    + " replytoaddress AS 'Reply To Address', subject AS 'Subject', snippet As 'Message Body', "
                    + "datesent AS 'Send Date', datereceive AS 'Received Date'" + " FROM Gmail_Store"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId;

        } else if (feature == "Calendar") {
            query = "SELECT title AS 'Title', description AS 'Event', location AS 'Location',"
                    + " start_time AS 'Start Time', end_time AS 'End Time', created_by AS 'Creator'"
                    + " FROM Calendar_Event" + " WHERE case_id = " + AndrospyMain.gb_CaseId
                    + " AND device_id = " + AndrospyMain.gb_DeviceId;

        } else if (feature == "YouTube") {
            query = "SELECT query AS 'Search' , search_date AS 'Time Stamp'" + " FROM Youtube_History"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId;

        } else if (feature.equals("FACEBOOK_MESSAGES")) {
            query = "SELECT IFNULL(sender, '') AS 'Sender'," + " IFNULL(text, '') AS 'Message',"
                    + " IFNULL(conversation_date, '') AS 'Date'," + " IFNULL(logitude, '') AS 'Longitude',"
                    + " IFNULL(latitude, '') AS 'Latitude'" + " FROM Facebook_Message" + " WHERE case_id = "
                    + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId;

        } else if (feature.equals("FACEBOOK_CONTACTS")) {
            query = "SELECT IFNULL(first_name, '') AS 'First Name'," + " IFNULL(last_name, '') AS 'Last Name',"
                    + " IFNULL(display_name, '') AS 'Display Name',"
                    + " IFNULL(added_time, '') AS 'Time Stamp'," + " IFNULL(type, '') AS 'Contact Type'"
                    + " FROM Fb_Contacts" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId;

        } else if (feature.equals("FACEBOOK_NOTIFICATIONS")) {
            query = "SELECT IFNULL(notification, '') AS 'Notification'," + " IFNULL(update_date, '') AS 'Date'"
                    + " FROM Facebook_Notifications" + " WHERE case_id = " + AndrospyMain.gb_CaseId
                    + " AND device_id = " + AndrospyMain.gb_DeviceId;

        } else if (feature.equals("LINKEDIN_PROFILE")) {
            query = "SELECT first_name AS 'First Name', last_name AS 'Last Name', display_name AS 'Display Name',"
                    + "country AS 'Country', join_date AS 'Join Date', connections AS 'No of Connections'"
                    + " FROM Linkedin_Profile" + " WHERE case_id = " + AndrospyMain.gb_CaseId
                    + " AND device_id = " + AndrospyMain.gb_DeviceId;

        } else if (feature.equals("LINKEDIN_CONNECTIONS")) {
            query = "SELECT IFNULL(first_name, '') AS 'First Name'," + " IFNULL(last_name, '') AS 'Last Name',"
                    + " IFNULL(display_name, '') AS 'Display Name'," + " IFNULL(title, '') AS 'Title'"
                    + " FROM Linkedin_Connections" + " WHERE case_id = " + AndrospyMain.gb_CaseId
                    + " AND device_id = " + AndrospyMain.gb_DeviceId;

        } else if (feature.equals("LINKEDIN_INVITATIONS")) {
            query = "SELECT IFNULL(from_display_name, '') AS 'Sender Name'," + " IFNULL(title, '') AS 'Title',"
                    + " IFNULL(invitation_date, '') AS 'Invitation Date'" + " FROM Linkedin_Invitation"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId;

        } else if (feature.equals("LINKEDIN_MESSAGES")) {
            query = "SELECT from_display_name AS 'Remote Party', from_title AS 'Remote Party Title',"
                    + " message_date AS 'Message Date', subject AS Subject, message_body AS Message"
                    + " FROM Linkedin_Message" + " WHERE case_id = " + AndrospyMain.gb_CaseId
                    + " AND device_id = " + AndrospyMain.gb_DeviceId;

        } else if (feature.equals("DEFAULT_BROWSER_HISTORY")) {
            query = "SELECT title AS Title, url AS URL, "
                    + "last_visit_date AS 'Last Visit Date', visits AS 'No of Visitis'"
                    + " FROM Browser_History" + " WHERE case_id = " + AndrospyMain.gb_CaseId
                    + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND browser = 'DEFAULTB'";

        } else if (feature.equals("DEFAULT_BOOKMARKS")) {
            query = "SELECT title AS Title, url AS URL, "
                    + "created_date AS 'Creaded Date', modified_date AS 'Modified Date', deleted AS Deleted,"
                    + "account_name AS 'Created By', account_type AS 'Account Type'" + " FROM Androspy_Bookmark"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId + " AND browser = 'DEFAULTB'";

        } else if (feature.equals("DEFAULT_WEB_FORM_DATA")) {
            query = "SELECT url AS 'URL', name AS 'Parameter Name', value AS 'Parameter Value'"
                    + " FROM WebForm f, WebFormData d"
                    + " WHERE f.case_id = d.case_id AND f.device_id = d.device_id" + " AND d.urlid = f.id"
                    + " AND d.case_id = " + AndrospyMain.gb_CaseId + " AND d.device_id = "
                    + AndrospyMain.gb_DeviceId;

        } else if (feature.equals("DEFAULT_COOKIES")) {
            query = "SELECT host AS 'Host', "
                    + "cookie_name AS 'Cookie Name', cookie_value AS 'Cookie Value', path AS Path, "
                    + "secure AS Secure, httponly AS 'Http Only', created_date AS 'Created Date', "
                    + "expire_date AS 'Expire Date', last_access_date AS 'Last Access Date'"
                    + " FROM Browser_Cookies" + " WHERE case_id = " + AndrospyMain.gb_CaseId
                    + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND browser = 'DEFAULTB'";

        } else if (feature.equals("DEFAULT_WEB_SEARCH")) {
            query = "SELECT search_text AS 'Search Text', " + "search_date AS 'Search Date'" + " FROM WebSearch"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId + " AND browser = 'DEFAULTB'";

        } else if (feature.equals("CHROME_BROWSER_HISTORY")) {
            query = "SELECT title AS Title, url AS URL, "
                    + "last_visit_date AS 'Last Visit Date', visits AS 'No of Visitis'"
                    + " FROM Browser_History" + " WHERE case_id = " + AndrospyMain.gb_CaseId
                    + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND browser = 'CHROME'";

        } else if (feature.equals("CHROME_COOKIES")) {
            query = "SELECT host AS 'Host', "
                    + "cookie_name AS 'Cookie Name', cookie_value AS 'Cookie Value', path AS Path, "
                    + "secure AS Secure, httponly AS 'Http Only', created_date AS 'Created Date', "
                    + "expire_date AS 'Expire Date', last_access_date AS 'Last Access Date'"
                    + " FROM Browser_Cookies" + " WHERE case_id = " + AndrospyMain.gb_CaseId
                    + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND browser = 'CHROME'";

        } else if (feature.equals("CHROME_WEB_SEARCH")) {
            query = "SELECT search_text AS 'Search Text', " + "search_date AS 'Search Date'" + " FROM WebSearch"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId + " AND browser = 'CHROME'";

        } else if (feature.equals("CHROME_CREDIT_CARD")) {
            query = "SELECT name AS Name, expire_month AS 'Expire Month', expire_year AS 'Exire Year', "
                    + "modified_date AS 'Modified Date'" + " FROM Browser_Credit_Card" + " WHERE case_id = "
                    + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId
                    + " AND browser = 'CHROME'";

        } else if (feature.equals("Firefox_BROWSER_HISTORY")) {
            query = "SELECT title AS Title, url AS URL, "
                    + "last_visit_date AS 'Last Visit Date', visits AS 'No of Visitis'"
                    + " FROM Browser_History" + " WHERE case_id = " + AndrospyMain.gb_CaseId
                    + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND browser = 'Firefox'";

        } else if (feature.equals("Firefox_BOOKMARKS")) {
            query = "SELECT title AS Title, url AS URL, "
                    + "created_date AS 'Creaded Date', modified_date AS 'Modified Date', deleted AS Deleted,"
                    + "account_name AS 'Created By', account_type AS 'Account Type'" + " FROM Androspy_Bookmark"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId + " AND browser = 'Firefox'";

        } else if (feature.equals("Firefox_WEB_SEARCH")) {
            query = "SELECT search_text AS 'Search Text', " + "search_date AS 'Search Date'" + " FROM WebSearch"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId + " AND browser = 'Firefox'";

        } else if (feature.equals("Firefox_COOKIES")) {
            query = "SELECT host AS 'Host', "
                    + "cookie_name AS 'Cookie Name', cookie_value AS 'Cookie Value', path AS Path, "
                    + "secure AS Secure, httponly AS 'Http Only', created_date AS 'Created Date', "
                    + "expire_date AS 'Expire Date', last_access_date AS 'Last Access Date'"
                    + " FROM Browser_Cookies" + " WHERE case_id = " + AndrospyMain.gb_CaseId
                    + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND browser = 'Firefox'";

        } else if (feature == "ALL_CALL_LOG") {
            query = "SELECT contact_no AS 'Contact No', name AS 'Name',"
                    + " date AS 'Contacted Date', duration AS 'Call Duration', "
                    + "countryiso AS 'Country Code', geolocationcode AS 'Geo Location'" + " FROM Event_Log"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId + " AND logtype = " + 100;

        } else if (feature == "INCOMING_CALLS") {
            query = "SELECT contact_no AS 'Contact No', name AS 'Name',"
                    + " date AS 'Contacted Date', duration AS 'Call Duration', "
                    + "countryiso AS 'Country Code', geolocationcode AS 'Geo Location'" + " FROM Event_Log"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId + " AND logtype = " + 100 + " AND type = " + 1;

        } else if (feature == "MISSED_CALLS") {
            query = "SELECT contact_no AS 'Contact No', name AS 'Name',"
                    + " date AS 'Contacted Date', duration AS 'Call Duration', "
                    + "countryiso AS 'Country Code', geolocationcode AS 'Geo Location'" + " FROM Event_Log"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId + " AND logtype = " + 100 + " AND type = " + 3;

        } else if (feature == "CANCELLED_CALLS") {
            query = "SELECT contact_no AS 'Contact No', name AS 'Name',"
                    + " date AS 'Contacted Date', duration AS 'Call Duration', "
                    + "countryiso AS 'Country Code', geolocationcode AS 'Geo Location'" + " FROM Event_Log"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId + " AND logtype = " + 500;

        } else if (feature == "OUTGOING_CALLS") {
            query = "SELECT contact_no AS 'Contact No', name AS 'Name',"
                    + " date AS 'Contacted Date', duration AS 'Call Duration', "
                    + "countryiso AS 'Country Code', geolocationcode AS 'Geo Location'" + " FROM Event_Log"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId + " AND logtype = " + 100 + " AND type = " + 2;

        } else if (feature == "ALL_SMS_LOG") {
            query = "SELECT contact_no AS 'Contact No', name AS 'Name'," + " date AS 'Contacted Date', "
                    + "messageid AS 'Message_Id', m_subject AS 'Message Subject', m_content AS 'Message Body', "
                    + "countryiso AS 'Country Code', geolocationcode AS 'Geo Location'" + " FROM Event_Log"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId + " AND logtype = " + 300;

        } else if (feature == "SMS_INBOX") {
            query = "SELECT contact_no AS 'Contact No', name AS 'Name'," + " date AS 'Contacted Date', "
                    + "messageid AS 'Message_Id', m_subject AS 'Message Subject', m_content AS 'Message Body', "
                    + "countryiso AS 'Country Code', geolocationcode AS 'Geo Location'" + " FROM Event_Log"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId + " AND logtype = " + 300 + " AND type = " + 1;

        } else if (feature == "SMS_OUTBOX") {
            query = "SELECT contact_no AS 'Contact No', name AS 'Name'," + " date AS 'Contacted Date', "
                    + "messageid AS 'Message_Id', m_subject AS 'Message Subject', m_content AS 'Message Body', "
                    + "countryiso AS 'Country Code', geolocationcode AS 'Geo Location'" + " FROM Event_Log"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId + " AND logtype = " + 300 + " AND type != " + 1;

        } else if (feature == "ALL_MMS_LOG") {
            query = "SELECT contact_no AS 'Contact No', name AS 'Name'," + " date AS 'Contacted Date', "
                    + "messageid AS 'Message_Id', m_subject AS 'Message Subject', m_content AS 'Message Body', "
                    + "countryiso AS 'Country Code', geolocationcode AS 'Geo Location'" + " FROM Event_Log"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId + " AND logtype = " + 200;

        } else if (feature == "MMS_INBOX") {
            query = "SELECT contact_no AS 'Contact No', name AS 'Name'," + " date AS 'Contacted Date', "
                    + "messageid AS 'Message_Id', m_subject AS 'Message Subject', m_content AS 'Message Body', "
                    + "countryiso AS 'Country Code', geolocationcode AS 'Geo Location'" + " FROM Event_Log"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId + " AND logtype = " + 200 + " AND type = " + 1;

        } else if (feature == "MMS_OUTBOX") {
            query = "SELECT contact_no AS 'Contact No', name AS 'Name'," + " date AS 'Contacted Date', "
                    + "messageid AS 'Message_Id', m_subject AS 'Message Subject', m_content AS 'Message Body', "
                    + "countryiso AS 'Country Code', geolocationcode AS 'Geo Location'" + " FROM Event_Log"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId + " AND logtype = " + 200 + " AND type != " + 1;

        } else if (feature == "Wi-Fi Access Points") {
            query = "SELECT ssid AS 'SSID', password AS 'Password', key_mgmt AS 'Key Management'"
                    + " FROM Wifi_Info" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId;

        } else if (feature.equals("Wi-Fi Access Points")) {
            query = "SELECT ssid AS 'SSID', password AS 'Password', key_mgmt AS 'Key Management'"
                    + " FROM Wifi_Info" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId;

        } else if (feature == "BT_USED") {
            query = "SELECT device_address AS 'Target Device BT Address', mimetype AS 'MIME Type', "
                    + " in_file_name AS 'File Name', totalbytes AS 'File Size', location AS Location, direction AS Direction, visibility AS Visibility, confirm AS Confirm,"
                    + " status AS 'Transfer Status', date AS 'Transfer Date', scanned As Scanned"
                    + " FROM Bluetooth_Tranfer" + " WHERE case_id = " + AndrospyMain.gb_CaseId
                    + " AND device_id = " + AndrospyMain.gb_DeviceId;

        } else if (feature == "BT_SEEN") {
            query = "SELECT bmac AS 'Bluetooth Address',"
                    + " device_name AS 'Device Name', seen_date AS 'Last Seen Date', 'used_date' AS 'Last_Paired_Date'"
                    + " FROM Bluetooth_Device" + " WHERE case_id = " + AndrospyMain.gb_CaseId
                    + " AND device_id = " + AndrospyMain.gb_DeviceId;

        } else if (feature == "Skype Account") {
            System.out.println("Skype Account");
            query = "SELECT skypename, fullname, birthday, country, city reg_date, gender"
                    + " FROM Skype_Account" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId;

        } else if (feature == "Skype Contacts") {
            System.out.println("Skype Contacts");
            query = "SELECT skypename, fullname, birthday, displayname, country, city, gender, phone"
                    + " FROM Skype_Contacts" + " WHERE case_id = " + AndrospyMain.gb_CaseId
                    + " AND device_id = " + AndrospyMain.gb_DeviceId;

        } else if (feature == "Skype Calls") {
            System.out.println("Skype Calls");
            query = "SELECT identity, display_name, call_duration, start_time_stamp" + " FROM Skype_Call"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId;

        } else if (feature == "Skype Messages") {
            System.out.println("Skype Messages");
            query = "SELECT author, from_display_name, dialog_partner, message, time_stamp"
                    + " FROM Skype_Message" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId;

        }

        if (query != ("")) {
            if (!bflagall) {
                query += " AND favourite = " + 1;
            }

            System.out.println("query: " + query);

            ResultSet rs = stmt.executeQuery(query);
            ResultSetMetaData rsmeta = rs.getMetaData();
            int colcount = rsmeta.getColumnCount();
            PdfPTable pdftable = new PdfPTable(colcount);
            pdftable.setWidthPercentage(100 / colcount);
            pdftable.setTotalWidth(527);
            pdftable.setLockedWidth(true);

            for (int i = 1; i <= colcount; i++) {
                PdfPCell c1 = new PdfPCell(new Phrase(rsmeta.getColumnLabel(i)));
                c1.setHorizontalAlignment(Element.ALIGN_CENTER);
                pdftable.addCell(c1);
            }
            pdftable.setHeaderRows(1);

            while (rs.next()) {
                for (int i = 1; i <= colcount; i++) {
                    System.out.println("add table cell report " + rs.getString(i));
                    pdftable.addCell(rs.getString(i));
                }
            }

            subpara.add(pdftable);
        }

    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:main.ItextPDF.java

public void createPdf(String filename, Person person) {
    // step 1//  ww w  .j a  va 2  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:main.java.ru.tsystems.restserviceclient.ServiceBean.java

public void downloadFile() throws IOException, org.json.simple.parser.ParseException {
    HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext()
            .getResponse();//  w  ww.  j a va  2  s.  c  o m
    try {
        // Get the text that will be added to the PDF
        String text = request;
        if (text == null || text.trim().length() == 0) {
            text = "No data.";
        }
        // step 1
        Document document = new Document();
        // step 2
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        PdfWriter.getInstance(document, baos);
        // step 3
        document.open();
        // step 4
        document.add(new Paragraph("Tickets from " + dateToString(dateFrom) + " to " + dateToString(dateTo)));

        PdfPTable table = new PdfPTable(7); // 3 columns.
        table.setWidthPercentage(100); //Width 100%
        table.setSpacingBefore(10f); //Space before table
        table.setSpacingAfter(10f); //Space after table

        //Set Column widths
        float[] columnWidths = { 1f, 1f, 1f, 1f, 1f, 1f, 1f };
        table.setWidths(columnWidths);

        PdfPCell cell1 = new PdfPCell(new Paragraph("Id"));
        ;
        PdfPCell cell2 = new PdfPCell(new Paragraph("Departure"));
        ;
        PdfPCell cell3 = new PdfPCell(new Paragraph("Passenger"));
        PdfPCell cell4 = new PdfPCell(new Paragraph("Route"));
        PdfPCell cell5 = new PdfPCell(new Paragraph("From"));
        PdfPCell cell6 = new PdfPCell(new Paragraph("To"));
        PdfPCell cell7 = new PdfPCell(new Paragraph("Train"));

        table.addCell(cell1);
        table.addCell(cell2);
        table.addCell(cell3);
        table.addCell(cell4);
        table.addCell(cell5);
        table.addCell(cell6);
        table.addCell(cell7);

        //parse data  
        JSONParser parser = new JSONParser();
        JSONArray array = (JSONArray) parser.parse(text);
        for (Object obj : array) {
            JSONObject objTemp = (JSONObject) obj;
            long ticketId = (long) objTemp.get("ticketId");
            String t = Long.toString(ticketId);
            table.addCell(t);
            table.addCell((String) objTemp.get("depatureTime"));
            table.addCell((String) objTemp.get("passenger"));
            table.addCell((String) objTemp.get("route"));
            table.addCell((String) objTemp.get("stationFrom"));
            table.addCell((String) objTemp.get("stationTo"));
            table.addCell((String) objTemp.get("train"));
        }

        document.add(table);

        // step 5
        document.close();

        // setting some response headers
        response.setHeader("Expires", "0");
        response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
        response.setHeader("Pragma", "public");
        // setting the content type
        response.setContentType("application/pdf");
        // the contentlength
        response.setContentLength(baos.size());
        // write ByteArrayOutputStream to the ServletOutputStream
        OutputStream os = response.getOutputStream();
        baos.writeTo(os);
        os.flush();
        os.close();
        FacesContext.getCurrentInstance().getResponseComplete();
    } catch (DocumentException e) {
        logger.error("Error!", e);
    }

}

From source file:managedbeans.Doctor.ImprimirAnamnesis.java

/**
 * Handles the HTTP <code>GET</code> method.
 *
 * @param request servlet request/*w  w  w. jav  a 2  s . c om*/
 * @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  . j  a v  a2  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 {// w  w  w  .  ja v  a2 s.c om
        //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:Modelo.CotizacionDAO.java

public void writePdf(OutputStream outputStream, Cotizacion x, int idcotizacion) throws Exception {

    DateFormat df = new SimpleDateFormat("dd/MM/YYYY");
    Calendar cdos = Calendar.getInstance();
    Date datediamas = new Date();
    Date dateaniomas = new Date();
    cdos.add(Calendar.DATE, 1);// ww  w. j  av a  2  s .  c  om
    datediamas = cdos.getTime();
    String fechadiamas = df.format(datediamas);
    cdos.add(Calendar.YEAR, 1);
    dateaniomas = cdos.getTime();
    String fechavencimiento = df.format(dateaniomas);

    Document document = new Document(PageSize.LETTER, 50, 50, 50, 30);
    Font boldFontTitulo = new Font(Font.FontFamily.HELVETICA, 12, Font.BOLD);
    Font boldFontTexto = new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD);
    Font FontTexto = new Font(Font.FontFamily.HELVETICA, 10);

    // document.setPageSize(null);
    PdfWriter writer = PdfWriter.getInstance(document, outputStream);

    Image imagen = Image.getInstance("http://54.67.56.185/BSeguros_pa18/img/BSeguroLogo.png");
    //      Image imagen = Image.getInstance("D:\\ALEX\\Bseguros\\web\\img\\Aseguradoras\\BSeguroLogo.png");
    Image imagen2 = Image.getInstance(
            "http://54.67.56.185/BSeguros_pa18/img/Aseguradoras/" + x.getId_aseguradora() + ".png");
    //Image imagen2 = Image.getInstance("D:\\ALEX\\Bseguros\\web\\img\\Aseguradoras\\Mapfre.png");

    document.open();

    PdfContentByte canvas = writer.getDirectContent();
    Rectangle rect = new Rectangle(36, 36, 579, 756);
    rect.setBorder(Rectangle.BOX);
    rect.setBorderWidth(2);
    canvas.rectangle(rect);

    document.addTitle("Cotizacion");
    document.addSubject("Cotizacion");
    document.addKeywords("Cotizacion, seguros");
    document.addAuthor("BSeguro");
    document.addCreator("Bseguro");

    imagen.scaleAbsoluteHeight(30f);
    imagen.setAbsolutePosition(45f, 720f);
    imagen2.scaleAbsoluteHeight(30f);
    imagen2.setAbsolutePosition(450f, 720f);
    document.add(imagen);
    document.add(imagen2);

    Paragraph paragraph2 = new Paragraph("DATOS DE TU POLIZA", boldFontTitulo);
    paragraph2.setAlignment(Element.ALIGN_CENTER);
    document.add(paragraph2);

    //creas una tabla con un ancho de 3 celdas, el salto a la siguiente fila sera automatico
    PdfPTable table = new PdfPTable(3);
    table.getDefaultCell().setBorder(0);
    PdfPCell cell;

    Paragraph saltodelinea = new Paragraph(" ");
    document.add(saltodelinea);

    document.add(new Paragraph(" Datos de tu poliza folio: " + "BC" + x.getId_aseguradora().substring(0, 1)
            + x.getMetododepago().substring(0, 1) + ": 0000" + idcotizacion, boldFontTitulo));
    document.add(new Paragraph(" Vigencia de la poliza del: " + fechadiamas + " al: " + fechavencimiento,
            boldFontTitulo));
    document.add(saltodelinea);

    document.add(new Paragraph(" Datos del Contratante: ", boldFontTitulo));
    //document.add(saltodelinea);

    //agrego otra tabla
    table = new PdfPTable(6);
    table.setWidthPercentage(100);
    table.getDefaultCell().setBorder(0);
    table.addCell(new Paragraph("Nombre: ", boldFontTexto));
    PdfPCell celdaNombre = new PdfPCell(
            new Paragraph(x.getNombre_contratante() + " " + x.getApellido_paterno(), FontTexto));
    celdaNombre.setColspan(5);
    celdaNombre.setBorder(0);
    table.addCell(celdaNombre);
    table.addCell(new Paragraph("RFC : ", boldFontTexto));
    PdfPCell celdaRFC = new PdfPCell(new Paragraph(x.getRfc(), FontTexto));
    celdaRFC.setColspan(5);
    celdaRFC.setBorder(0);
    table.addCell(celdaRFC);
    table.addCell(new Paragraph("Direccion: ", boldFontTexto));
    PdfPCell celdaDir = new PdfPCell(
            new Paragraph(x.getCall() + ", " + x.getNo_ext() + ", " + x.getNo_int() + ", " + x.getColonia()
                    + ", " + x.getDelegacion() + ", " + x.getEstado() + ", " + x.getCp(), FontTexto));
    celdaDir.setColspan(5);
    celdaDir.setBorder(0);
    table.addCell(celdaDir);
    table.addCell(new Paragraph("Email: ", boldFontTexto));
    table.addCell(AddCell(x.getMail(), 5));
    table.addCell(new Paragraph("Telefono ", boldFontTexto));
    PdfPCell celdaTel = new PdfPCell(new Paragraph(x.getTelefono(), FontTexto));
    celdaTel.setColspan(5);
    celdaTel.setBorder(0);
    table.addCell(celdaTel);

    document.add(table);
    document.add(saltodelinea);

    document.add(new Paragraph(" Datos del Vehiculo: ", boldFontTitulo));
    //      document.add(saltodelinea);

    //agrego otra tabla
    table = new PdfPTable(6);
    table.setWidthPercentage(100);
    table.getDefaultCell().setBorder(0);
    table.addCell(new Paragraph("Marca: ", boldFontTexto));
    table.addCell(AddCell(x.getId_marca(), 5));
    table.addCell(new Paragraph("Modelo:", boldFontTexto));
    table.addCell(AddCell(x.getId_anio().toString(), 5));
    table.addCell(new Paragraph("Tipo: ", boldFontTexto));
    table.addCell(AddCell(x.getId_submarca(), 5));
    table.addCell(new Paragraph("Version:  ", boldFontTexto));
    table.addCell(AddCell(x.getId_modelo(), 5));
    table.addCell(new Paragraph("No. De Serie: ", boldFontTexto));
    table.addCell(AddCell(x.getSerie(), 5));

    document.add(table);
    document.add(saltodelinea);

    document.add(new Paragraph(" Informacion de la Poliza: ", boldFontTitulo));
    //    document.add(saltodelinea);

    //agrego otra tabla
    table = new PdfPTable(6);
    table.setWidthPercentage(100);
    table.getDefaultCell().setBorder(0);
    table.addCell(new Paragraph("Pago: ", boldFontTexto));
    table.addCell(AddCell(x.getTipo_pago(), 5));
    table.addCell(new Paragraph("Aseguradora: ", boldFontTexto));
    table.addCell(AddCell(x.getId_aseguradora(), 5));

    document.add(table);
    document.add(saltodelinea);

    document.add(new Paragraph(" Detalles de la Cobertura: Cobertura Amplia ", boldFontTitulo));
    //  document.add(saltodelinea);

    //agrego otra tabla
    table = new PdfPTable(3);
    table.setWidthPercentage(100);
    table.getDefaultCell().setBorder(0);
    table.addCell(new Paragraph("Cobertura ", boldFontTexto));
    table.addCell(new Paragraph("Responsabilidad Civil", boldFontTexto));
    table.addCell(new Paragraph("Deducible ", boldFontTexto));
    table.addCell(new Paragraph("Daos Materiales", FontTexto));
    table.addCell(new Paragraph("Valor Comercial", FontTexto));
    table.addCell(new Paragraph("5%", FontTexto));
    table.addCell(new Paragraph("Robo Total", FontTexto));
    table.addCell(new Paragraph("Valor Comercial", FontTexto));
    table.addCell(new Paragraph("10%", FontTexto));
    table.addCell(new Paragraph("Responsabilidad Civil", FontTexto));
    table.addCell(new Paragraph("$4,000,000.00", FontTexto));
    table.addCell(new Paragraph("", FontTexto));
    table.addCell(new Paragraph("Gastos Medicos Ocupantes", FontTexto));
    table.addCell(new Paragraph("$500,000.00", FontTexto));
    table.addCell(new Paragraph("", FontTexto));
    table.addCell(new Paragraph("Asistencia Legal", FontTexto));
    table.addCell(new Paragraph("Amparada", FontTexto));
    table.addCell(new Paragraph("", FontTexto));
    table.addCell(new Paragraph("Asistencia Vial", FontTexto));
    table.addCell(new Paragraph("Amparada", FontTexto));
    table.addCell(new Paragraph("", FontTexto));

    document.add(table);
    document.add(saltodelinea);

    document.add(new Paragraph(" Informacion del Pago ", boldFontTitulo));
    document.add(new Paragraph(" Instrumento de Pago: " + x.getMetododepago(), boldFontTexto));

    //agrego otra tabla
    table = new PdfPTable(6);
    table.setWidthPercentage(100);
    table.getDefaultCell().setBorder(0);
    table.addCell(AddCell("Concepto ", 2));
    table.addCell(AddCell("Monto", 4));
    table.addCell(AddCell("Prima Total ", 2));
    table.addCell(AddCell(x.getMonto(), 4));
    table.addCell(AddCell("Prima Inicial", 2));
    table.addCell(AddCell(x.getMonto(), 4));
    table.addCell(AddCell("Pago Subsecuente ", 2));
    table.addCell(AddCell("0", 4));

    document.add(table);
    document.add(saltodelinea);

    if (x.getCobertura_auto_siempre() == true) {

        document.add(new Paragraph(" Informacion de Modulos HDI ", boldFontTitulo));
        table = new PdfPTable(6);
        table.setWidthPercentage(100);
        table.getDefaultCell().setBorder(0);
        table.addCell(AddCell("Modulos ", 2));
        table.addCell(AddCell("Contratados", 4));
        table.addCell(AddCell("HDI - Autos por Siempre ", 2));
        table.addCell(AddCell("$ 1,799.00", 4));
        document.add(table);

    } else {
        if (x.getCobertura_auto_amante() == true) {

            document.add(new Paragraph(" Informacion de Modulos HDI ", boldFontTitulo));
            table = new PdfPTable(6);
            table.setWidthPercentage(100);
            table.getDefaultCell().setBorder(0);
            table.addCell(AddCell("Modulos ", 2));
            table.addCell(AddCell("Contratados", 4));
            table.addCell(AddCell("HDI - Amante de los Autos ", 2));
            table.addCell(AddCell("$ 1,799.00", 4));
            document.add(table);

        } else {

        }
        document.add(saltodelinea);
    }
    document.add(new Paragraph("* Estaras asegurado a partir de las 12 horas del siguiente dia habil.",
            boldFontTexto));

    document.close();

}

From source file:modelo.crearPdf.java

public String pdf(int tiquet, int idOrden, String codOrden) {
    try {//from   w w w .j a  va2 s .c  o m

        String sql = "Select * from tiquet where idorden = '" + idOrden + "' and tiquet='" + tiquet + "'";
        rs = Consultar(sql);
        int id = 0;
        int numTiquet = 0;
        String ob = "";
        tiquet verTiquet = new tiquet();
        colores verColor = new colores();
        String colorUno = "";
        String colorDos = "";
        System.out.print("id de la orden en el tiquet:" + idOrden);
        ArrayList<String> lista = new ArrayList<String>();
        int c1 = 0, c2 = 0, c3 = 0, c4 = 0, c5 = 0, c6 = 0, c7 = 0, c8 = 0, c9 = 0, c10 = 0, c11 = 0, c12 = 0,
                c13 = 0, c14 = 0, c15 = 0;
        int c16 = 0, c17 = 0, c18 = 0, c19 = 0, c20 = 0, c21 = 0, c22 = 0, c23 = 0, c24 = 0, c25 = 0, c26 = 0,
                c27 = 0, c28 = 0, c29 = 0;
        int c30 = 0, c31 = 0, c32 = 0, c33 = 0;
        String observacion = "";
        String verificacion = "";
        //rs.last();
        int cuantos = rs.getRow();
        //System.out.print("puestos:" + cuantos+ "orden: " + codOrden + "tiquet: " + tiquet);
        //Creamos el CHUNK definiendo su tipo de letra, tamao
        Chunk direccion = new Chunk("Calle 12 # 6-68 Nia Ceci",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Tiq = new Chunk("Tiquet #",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValTiq = new Chunk("" + tiquet,
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Tel = new Chunk("Tel: 5783364",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Ref = new Chunk("Ref",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValRef = new Chunk("",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Correo = new Chunk("calzadoseiya@gmail.com",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK));
        Chunk Par = new Chunk("Pares",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValPar = new Chunk("",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk FechaTiq = new Chunk("Fecha",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk FechaTiq2 = new Chunk("",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Orden = new Chunk("Orden",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValOrd = new Chunk("",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Cor = new Chunk("CORTADA",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Guar = new Chunk("GUARNICION",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Mon = new Chunk("MONTADA",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Emp = new Chunk("EMPLANTILLADA",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK));
        Chunk OBSER = new Chunk("OBSERVACION",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Col1 = new Chunk("Color 1",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK));
        Chunk Col2 = new Chunk("Color 2",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK));
        Chunk Encabezado = new Chunk("SEIYA",
                FontFactory.getFont(FontFactory.HELVETICA_BOLD, 11, Font.NORMAL, BaseColor.BLACK));
        Chunk num21 = new Chunk("21",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num22 = new Chunk("22",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num23 = new Chunk("23",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num24 = new Chunk("24",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num25 = new Chunk("25",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num26 = new Chunk("26",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num27 = new Chunk("27",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num28 = new Chunk("28",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num29 = new Chunk("29",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num30 = new Chunk("30",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num31 = new Chunk("31",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num32 = new Chunk("32",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num33 = new Chunk("33",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num34 = new Chunk("34",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num35 = new Chunk("35",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num36 = new Chunk("36",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num37 = new Chunk("37",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num38 = new Chunk("38",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num39 = new Chunk("39",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num40 = new Chunk("40",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num41 = new Chunk("41",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num42 = new Chunk("42",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num43 = new Chunk("43",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num44 = new Chunk("44",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));

        //Fecha actual en formato completo:
        //Tue Sep 23 01:18:48 CEST 2014
        Date fechaActual = new Date();

        //Formateando la fecha:
        DateFormat formatoHora = new SimpleDateFormat("HH-mm-ss");
        DateFormat formatoFecha = new SimpleDateFormat("yyyy-MM-dd");
        DateFormat Fecha = new SimpleDateFormat("dd/MM/yyyy");
        //  System.out.println("Fecha: "+formatoFecha.format(fechaActual)+" Son las: "+formatoHora.format(fechaActual));
        String fe = Fecha.format(fechaActual);
        //Directorio destino para las descargas
        File folder = new File("c:\\seiya\\tiquets");

        //Crea el directorio de destino en caso de que no exista
        folder.mkdirs();

        int numeroAleatorio = (int) (Math.random() * 2500 + 1);
        //Nombre del fichero <strong>PDF</strong> Resultante de la ejecucion
        String dir = "C:\\seiya\\tiquets\\Tiquet_" + tiquet + ".pdf";
        // El archivo pdf que vamos a generar
        FileOutputStream fileOutputStream = new FileOutputStream(dir);
        Rectangle pageSize = new Rectangle(300f, 792f); //ancho y alto
        //Creacion del documento con un tamao y unos margenes predeterminados

        Document document = new Document(pageSize, 1, 1, 1, 1);
        // Obtener la instancia del PdfWriter
        PdfWriter writer = PdfWriter.getInstance(document, fileOutputStream);

        //Opens the document.
        //You have to open the document before you can begin to add content to the body of the document.
        document.open();
        //**************************************************************

        //Ejemplos de TABLE
        titulo = new Chunk("", FontFactory.getFont(FontFactory.COURIER, 20, Font.UNDERLINE, BaseColor.BLACK));
        document.add(titulo);
        //Aadir tabla 5 columnas
        PdfPTable table = new PdfPTable(15);
        //Aadir CABECERA

        PdfPCell cell = new PdfPCell();
        cell.setColspan(15);
        table.addCell(cell);

        Image image = Image.getInstance("logo.png");
        //    String col = "jhon";
        cell = new PdfPCell(image);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(4);
        cell.setRowspan(7);
        table.addCell(cell);
        /*
        cell = new PdfPCell(new Phrase("imagen:"));
        cell.setColspan(4);
        cell.setRowspan(7);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //cell.setBackgroundColor(BaseColor.GRAY);
        table.addCell(cell);
                
        /*table.addCell(createImageCell(IMG1));*/
        cell = new PdfPCell(new Phrase(direccion));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(6);
        cell.setRowspan(2);

        table.addCell(cell);

        while (rs.next()) {

            c1 = rs.getInt(1);
            c2 = rs.getInt(2);
            c3 = rs.getInt(3);
            c4 = rs.getInt(4);
            c5 = rs.getInt(5);
            observacion = rs.getString(6);
            verificacion = rs.getString(7);
            c8 = rs.getInt(8);
            c9 = rs.getInt(9);
            c10 = rs.getInt(10);
            c11 = rs.getInt(11);
            c12 = rs.getInt(12);
            c13 = rs.getInt(13);
            c14 = rs.getInt(14);
            c15 = rs.getInt(15);
            c16 = rs.getInt(16);
            c17 = rs.getInt(17);
            c18 = rs.getInt(18);
            c19 = rs.getInt(19);
            c20 = rs.getInt(20);
            c21 = rs.getInt(21);
            c22 = rs.getInt(22);
            c23 = rs.getInt(23);
            c24 = rs.getInt(24);
            c25 = rs.getInt(25);
            c26 = rs.getInt(26);
            c27 = rs.getInt(27);
            c28 = rs.getInt(28);
            c29 = rs.getInt(29);
            c30 = rs.getInt(30);
            c31 = rs.getInt(31);
            c32 = rs.getInt(32);
            c33 = rs.getInt(33);

            String c01 = " ", c02 = " ", c03 = " ", c04 = " ", c05 = " ", c06 = " ", c07 = " ", c08 = " ",
                    c09 = " ", c010 = " ", c011 = " ", c012 = " ";
            String c013 = " ", c014 = " ", c015 = " ", c016 = " ", c017 = " ", c018 = " ", c019 = " ",
                    c020 = " ", c021 = " ", c022 = " ", c023 = " ", c024 = " ";
            String c025 = " ", c026 = " ", c027 = " ", c028 = " ", c029 = " ", c030 = " ", c031 = " ",
                    c032 = " ", c033 = " ", c034 = " ";
            if (c1 != 0)
                c01 = String.valueOf(c1);
            if (c2 != 0)
                c02 = String.valueOf(c2);
            if (c3 != 0)
                c03 = String.valueOf(c3);
            if (c4 != 0)
                c04 = String.valueOf(c4);
            if (c5 != 0)
                c05 = String.valueOf(c5);
            if (c8 != 0)
                c08 = String.valueOf(c8);
            if (c9 != 0)
                c09 = String.valueOf(c9);
            if (c10 != 0)
                c010 = String.valueOf(c10);
            if (c11 != 0)
                c011 = String.valueOf(c11);
            if (c12 != 0)
                c012 = String.valueOf(c12);
            if (c13 != 0)
                c013 = String.valueOf(c13);
            if (c14 != 0)
                c014 = String.valueOf(c14);
            if (c15 != 0)
                c015 = String.valueOf(c15);
            if (c16 != 0)
                c016 = String.valueOf(c16);
            if (c17 != 0)
                c017 = String.valueOf(c17);
            if (c18 != 0)
                c018 = String.valueOf(c18);
            if (c19 != 0)
                c019 = String.valueOf(c19);
            if (c20 != 0)
                c020 = String.valueOf(c20);
            if (c21 != 0)
                c021 = String.valueOf(c21);
            if (c22 != 0)
                c022 = String.valueOf(c22);
            if (c23 != 0)
                c023 = String.valueOf(c23);
            if (c24 != 0)
                c024 = String.valueOf(c24);
            if (c25 != 0)
                c025 = String.valueOf(c25);
            if (c26 != 0)
                c026 = String.valueOf(c26);
            if (c27 != 0)
                c027 = String.valueOf(c27);
            if (c28 != 0)
                c028 = String.valueOf(c28);
            if (c29 != 0)
                c029 = String.valueOf(c29);
            if (c30 != 0)
                c030 = String.valueOf(c30);
            if (c31 != 0)
                c031 = String.valueOf(c31);
            if (c32 != 0)
                c032 = String.valueOf(c32);
            if (c33 != 0)
                c033 = String.valueOf(c33);

            colorUno = verColor.consultarNombreColorUno(c4);
            colorDos = verColor.consultarNombreColorDos(c5);
            ob = verTiquet.ConsultaObservacion(tiquet);
            Chunk ValCol1 = new Chunk(colorUno,
                    FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
            Chunk ValCol2 = new Chunk(colorDos,
                    FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
            Chunk ValObserv = new Chunk(ob,
                    FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));

            System.out.print("Color Uno: " + colorUno);

            cell = new PdfPCell(new Phrase(Tiq));
            cell.setColspan(3);
            cell.setRowspan(2);
            cell.setVerticalAlignment(Element.ALIGN_CENTER);
            //cell.setBackgroundColor(BaseColor.GRAY);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase("" + tiquet));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            //cell.setBackgroundColor(BaseColor.ORANGE);
            cell.setColspan(2);
            cell.setRowspan(2);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(Tel));
            cell.setColspan(6);
            cell.setRowspan(2);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            //cell.setBackgroundColor(BaseColor.CYAN);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(Ref));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            //cell.setBackgroundColor(BaseColor.ORANGE);
            cell.setColspan(2);
            cell.setRowspan(2);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase("" + c8));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            //cell.setBackgroundColor(BaseColor.ORANGE);
            cell.setColspan(3);
            cell.setRowspan(2);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(Correo));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(6);
            cell.setRowspan(2);//para eliminar espacio cabecera reemplazo el 2 por 3
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(Par));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            //cell.setBackgroundColor(BaseColor.ORANGE);
            cell.setColspan(2);
            cell.setRowspan(2);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase("" + c9));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            //cell.setBackgroundColor(BaseColor.ORANGE);
            cell.setColspan(3);
            cell.setRowspan(2);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(FechaTiq));//espacio intermedio cabecera
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(2);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(fe));//espacio intermedio cabecera
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(4);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(Orden));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            //cell.setBackgroundColor(BaseColor.ORANGE);
            cell.setColspan(2);
            cell.setRowspan(1);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase("" + codOrden));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            //cell.setBackgroundColor(BaseColor.ORANGE);
            cell.setColspan(3);
            cell.setRowspan(1);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(Cor));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(4);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(""));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(11);
            cell.setRowspan(1);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(Guar));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(4);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(""));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(11);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(Mon));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(4);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(""));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(11);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(Emp));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(4);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(""));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(11);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(OBSER));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(4);
            cell.setRowspan(2);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(ValObserv));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(11);
            cell.setRowspan(2);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(Col1));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(3);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(ValCol1));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(4);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(Col2));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(3);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(ValCol2));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(5);
            table.addCell(cell);

            table.addCell(new Phrase(num21));
            table.addCell(new Phrase(num22));
            table.addCell(new Phrase(num23));
            table.addCell(new Phrase(num24));
            table.addCell(new Phrase(num25));
            table.addCell(new Phrase(num26));
            table.addCell(new Phrase(num27));
            table.addCell(new Phrase(num28));
            table.addCell(new Phrase(num29));
            table.addCell(new Phrase(num30));
            table.addCell(new Phrase(num31));
            table.addCell(new Phrase(num32));
            table.addCell(new Phrase(num33));
            table.addCell(new Phrase(num34));
            table.addCell(new Phrase(num35));

            table.addCell("" + c010);
            table.addCell("" + c011);
            table.addCell("" + c012);
            table.addCell("" + c013);
            table.addCell("" + c014);
            table.addCell("" + c015);
            table.addCell("" + c016);
            table.addCell("" + c017);
            table.addCell("" + c018);
            table.addCell("" + c019);
            table.addCell("" + c020);
            table.addCell("" + c021);
            table.addCell("" + c022);
            table.addCell("" + c023);
            table.addCell("" + c024);

            table.addCell(new Phrase(num36));
            table.addCell(new Phrase(num37));
            table.addCell(new Phrase(num38));
            table.addCell(new Phrase(num39));
            table.addCell(new Phrase(num40));
            table.addCell(new Phrase(num41));
            table.addCell(new Phrase(num42));
            table.addCell(new Phrase(num43));
            table.addCell(new Phrase(num44));
            table.addCell(" ");
            table.addCell(" ");
            table.addCell(" ");
            table.addCell(" ");
            table.addCell(" ");
            table.addCell(" ");

            table.addCell("" + c025);
            table.addCell("" + c026);
            table.addCell("" + c027);
            table.addCell("" + c028);
            table.addCell("" + c029);
            table.addCell("" + c030);
            table.addCell("" + c031);
            table.addCell("" + c032);
            table.addCell("" + c033);
            table.addCell("");
            table.addCell("");
            table.addCell("");
            table.addCell("");
            table.addCell("");
            table.addCell("");

            table.setWidthPercentage(100f);
            table.setHorizontalAlignment(Element.ALIGN_RIGHT);

            document.add(table);

            // String cadena="";
            Chunk cadena = null;
            for (int i = 1; i <= 4; i++) {
                //Chunk chunkSeparador =  new Chunk(SEPARADOR);
                // document.add(chunkSeparador);
                // document.add(Chunk.NEWLINE);

                PdfPTable tabla = new PdfPTable(15);
                if (i == 1)
                    cadena = Emp;
                if (i == 2)
                    cadena = Mon;

                if (i == 3) {
                    cadena = Guar;

                }
                if (i == 4)
                    cadena = Cor;

                cell = new PdfPCell(
                        new Phrase("-----------------------------------------------------------------"));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(15);
                cell.setRowspan(1);
                tabla.addCell(cell);

                cell = new PdfPCell(new Phrase(Encabezado));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(5);
                cell.setRowspan(1);
                tabla.addCell(cell);
                cell = new PdfPCell(new Phrase(cadena));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(4);
                cell.setRowspan(1);
                tabla.addCell(cell);
                cell = new PdfPCell(new Phrase(Tiq));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(3);
                cell.setRowspan(1);
                tabla.addCell(cell);
                cell = new PdfPCell(new Phrase("" + tiquet));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(3);
                cell.setRowspan(1);
                tabla.addCell(cell);

                cell = new PdfPCell(new Phrase(Par));
                cell.setHorizontalAlignment(Font.BOLD);
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(2);
                cell.setRowspan(1);
                tabla.addCell(cell);
                cell = new PdfPCell(new Phrase("" + c9));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(3);
                cell.setRowspan(1);
                tabla.addCell(cell);

                cell = new PdfPCell(new Phrase(""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(4);
                cell.setRowspan(1);
                tabla.addCell(cell);
                cell = new PdfPCell(new Phrase(Ref));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(3);
                cell.setRowspan(1);
                tabla.addCell(cell);
                cell = new PdfPCell(new Phrase("" + c8));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(3);
                cell.setRowspan(1);
                tabla.addCell(cell);

                cell = new PdfPCell(new Phrase(Col1));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(3);
                tabla.addCell(cell);
                cell = new PdfPCell(new Phrase(ValCol1));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(4);
                tabla.addCell(cell);

                cell = new PdfPCell(new Phrase(Col2));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(3);
                tabla.addCell(cell);
                cell = new PdfPCell(new Phrase(ValCol2));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(5);
                tabla.addCell(cell);

                tabla.addCell(new Phrase(num21));
                tabla.addCell(new Phrase(num22));
                tabla.addCell(new Phrase(num23));
                tabla.addCell(new Phrase(num24));
                tabla.addCell(new Phrase(num25));
                tabla.addCell(new Phrase(num26));
                tabla.addCell(new Phrase(num27));
                tabla.addCell(new Phrase(num28));
                tabla.addCell(new Phrase(num29));
                tabla.addCell(new Phrase(num30));
                tabla.addCell(new Phrase(num31));
                tabla.addCell(new Phrase(num32));
                tabla.addCell(new Phrase(num33));
                tabla.addCell(new Phrase(num34));
                tabla.addCell(new Phrase(num35));

                tabla.addCell("" + c010);
                tabla.addCell("" + c011);
                tabla.addCell("" + c012);
                tabla.addCell("" + c013);
                tabla.addCell("" + c014);
                tabla.addCell("" + c015);
                tabla.addCell("" + c016);
                tabla.addCell("" + c017);
                tabla.addCell("" + c018);
                tabla.addCell("" + c019);
                tabla.addCell("" + c020);
                tabla.addCell("" + c021);
                tabla.addCell("" + c022);
                tabla.addCell("" + c023);
                tabla.addCell("" + c024);

                tabla.addCell(new Phrase(num36));
                tabla.addCell(new Phrase(num37));
                tabla.addCell(new Phrase(num38));
                tabla.addCell(new Phrase(num39));
                tabla.addCell(new Phrase(num40));
                tabla.addCell(new Phrase(num41));
                tabla.addCell(new Phrase(num42));
                tabla.addCell(new Phrase(num43));
                tabla.addCell(new Phrase(num44));
                tabla.addCell(" ");
                tabla.addCell(" ");
                tabla.addCell(" ");
                tabla.addCell(" ");
                tabla.addCell(" ");
                tabla.addCell(" ");

                tabla.addCell("" + c025);
                tabla.addCell("" + c026);
                tabla.addCell("" + c027);
                tabla.addCell("" + c028);
                tabla.addCell("" + c029);
                tabla.addCell("" + c030);
                tabla.addCell("" + c031);
                tabla.addCell("" + c032);
                tabla.addCell("" + c033);
                tabla.addCell("");
                tabla.addCell("");
                tabla.addCell("");
                tabla.addCell("");
                tabla.addCell("");
                tabla.addCell("");

                tabla.setWidthPercentage(100f);
                tabla.setHorizontalAlignment(Element.ALIGN_RIGHT);

                document.add(tabla);

            }
            //FIN Ejemplos de TABLE

        }

        document.close();

        return "exito";

    } catch (Exception ex) {
        System.out.println(ex.getMessage());
        return "Error al Generar el PDF";
    }

}

From source file:modelo.impOrdenCarta.java

public boolean impOrden(int idOrden, String codOrden, int numRegTiq) {
    try {//from w w w  .  j a v  a 2  s.  c om

        int id = 0;
        int numTiquet = 0;
        String ob = "";
        colores verColor = new colores();
        String colorUno = "";
        String colorDos = "";
        ArrayList<String> lista = new ArrayList<String>();
        int c1 = 0, c2 = 0, c3 = 0, c4 = 0, c5 = 0, c6 = 0, c7 = 0, c8 = 0, c9 = 0, c10 = 0, c11 = 0, c12 = 0,
                c13 = 0, c14 = 0, c15 = 0;
        int c16 = 0, c17 = 0, c18 = 0, c19 = 0, c20 = 0, c21 = 0, c22 = 0, c23 = 0, c24 = 0, c25 = 0, c26 = 0,
                c27 = 0, c28 = 0, c29 = 0;
        int c30 = 0, c31 = 0, c32 = 0, c33 = 0;
        String observacion = "";
        int CanTotal = 0;

        int idCliente = 0;
        String ciu = "";
        String fecped = "";
        String fecent = "";

        for (orden ord : new orden().CargarDatosOrden(codOrden)) {
            idCliente = ord.getCliente();
            ciu = ord.getCiudad();
            fecped = ord.getPedido();
            fecent = ord.getEntrega();
        }
        String nomCliente = nuevaOrden.ConsultarNombreCliente(idCliente);

        Chunk idClient = new Chunk(nomCliente,
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk direccion = new Chunk("Calle 12 # 6-68 Nia Ceci",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 12, Font.NORMAL, BaseColor.BLACK));
        Chunk Tiq = new Chunk("TK",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValTiq = new Chunk("",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Tel = new Chunk("Tel: 5783364",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 12, Font.NORMAL, BaseColor.BLACK));
        Chunk Ref = new Chunk("REF",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValRef = new Chunk("",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Correo = new Chunk("calzadoseiya@gmail.com",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 12, Font.NORMAL, BaseColor.BLACK));
        Chunk Cliente = new Chunk("CLIENTE",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk FecEnt = new Chunk("FECHA ENTREGA",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValFecEnt = new Chunk(fecent,
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk FecPed = new Chunk("FECHA PEDIDO",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValFecPed = new Chunk(fecped,
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk FechaTiq2 = new Chunk("",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Orden = new Chunk("ORDEN",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValOrd = new Chunk("",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Ciudad = new Chunk("CIUDAD",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValCiudad = new Chunk(ciu,
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Cant = new Chunk("CANT.",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Mon = new Chunk("MONTADA",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Emp = new Chunk("EMPLANTILLADA",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK));
        Chunk OBSER = new Chunk("OBSERVACION",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Col1 = new Chunk("Color 1",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK));
        Chunk Col2 = new Chunk("Color 2",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK));
        Chunk Encabezado = new Chunk("SEIYA",
                FontFactory.getFont(FontFactory.HELVETICA_BOLD, 11, Font.NORMAL, BaseColor.BLACK));
        Chunk num21 = new Chunk("21",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num22 = new Chunk("22",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num23 = new Chunk("23",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num24 = new Chunk("24",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num25 = new Chunk("25",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num26 = new Chunk("26",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num27 = new Chunk("27",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num28 = new Chunk("28",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num29 = new Chunk("29",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num30 = new Chunk("30",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num31 = new Chunk("31",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num32 = new Chunk("32",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num33 = new Chunk("33",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num34 = new Chunk("34",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num35 = new Chunk("35",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num36 = new Chunk("36",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num37 = new Chunk("37",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num38 = new Chunk("38",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num39 = new Chunk("39",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num40 = new Chunk("40",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num41 = new Chunk("41",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num42 = new Chunk("42",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num43 = new Chunk("43",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num44 = new Chunk("44",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));

        File folder = new File("c:\\seiya\\ordenes");
        folder.mkdirs();
        String dir = "C:\\seiya\\ordenes\\Orden_" + codOrden + ".pdf";
        // El archivo pdf que vamos a generar
        FileOutputStream fileOutputStream = new FileOutputStream(dir);
        Rectangle pageSize = new Rectangle(792f, 612f);

        Document document = new Document(pageSize, 1, 1, 1, 1);
        PdfWriter writer = PdfWriter.getInstance(document, fileOutputStream);
        document.open();

        PdfPTable table = new PdfPTable(40);
        PdfPCell cell = new PdfPCell();

        Image image = Image.getInstance("logo.png");
        //    String col = "jhon";
        cell = new PdfPCell(image);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(7);
        cell.setRowspan(7);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(direccion));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(33);
        cell.setRowspan(2);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Tel));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(33);
        cell.setRowspan(2);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Correo));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(33);
        cell.setRowspan(2);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(" "));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(33);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Tiq));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Orden));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(codOrden));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Cliente));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(idClient));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(9);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Ciudad));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(ValCiudad));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(4);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(FecPed));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(ValFecPed));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(4);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(FecEnt));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(ValFecEnt));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(4);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(""));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Ref));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Cant));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        table.addCell(new Phrase(num21));
        table.addCell(new Phrase(num22));
        table.addCell(new Phrase(num23));
        table.addCell(new Phrase(num24));
        table.addCell(new Phrase(num25));
        table.addCell(new Phrase(num26));
        table.addCell(new Phrase(num27));
        table.addCell(new Phrase(num28));
        table.addCell(new Phrase(num29));
        table.addCell(new Phrase(num30));
        table.addCell(new Phrase(num31));
        table.addCell(new Phrase(num32));
        table.addCell(new Phrase(num33));
        table.addCell(new Phrase(num34));
        table.addCell(new Phrase(num35));
        table.addCell(new Phrase(num36));
        table.addCell(new Phrase(num37));
        table.addCell(new Phrase(num38));
        table.addCell(new Phrase(num39));
        table.addCell(new Phrase(num40));
        table.addCell(new Phrase(num41));
        table.addCell(new Phrase(num42));
        table.addCell(new Phrase(num43));

        cell = new PdfPCell(new Phrase(Col1));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Col2));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(OBSER));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(5);
        cell.setRowspan(1);
        table.addCell(cell);

        ArrayList<String> resultat;
        resultat = nuevoTiquet.consultarTiquetporOrden(idOrden);
        Iterator<String> tiquetIterator = resultat.iterator();

        while (tiquetIterator.hasNext()) {

            String valorTiquet = tiquetIterator.next();
            System.out.print(valorTiquet + " ------ ");
            int tiq = Integer.parseInt(valorTiquet);
            ArrayList<tiquet> listaDatosTiquet;
            listaDatosTiquet = nuevoTiquet.conten(idOrden, tiq);//La consulta tiene que retornar un ArrayList

            for (tiquet ord : new tiquet().conten(idOrden, tiq)) {
                System.out.print("Referencia: " + nuevoTiquet.ConsultarReferencia(tiq, idOrden));
                c1 = ord.getTiquet();
                c2 = ord.getIdorden();
                observacion = ord.getObservacion();
                c4 = nuevoTiquet.ConsultarReferencia(tiq, idOrden);
                c5 = nuevoTiquet.ConsultarCantidad(tiq, idOrden);
                c8 = ord.getN21();
                c9 = ord.getN22();
                c10 = ord.getN23();
                c11 = ord.getN24();
                c12 = ord.getN25();
                c13 = ord.getN26();
                c14 = ord.getN27();
                c15 = ord.getN28();
                c16 = ord.getN29();
                c17 = ord.getN30();
                c18 = ord.getN31();
                c19 = ord.getN32();
                c20 = ord.getN33();
                c21 = ord.getN34();
                c22 = ord.getN35();
                c23 = ord.getN36();
                c24 = ord.getN37();
                c25 = ord.getN38();
                c26 = ord.getN39();
                c27 = ord.getN40();
                c28 = ord.getN41();
                c29 = ord.getN42();
                c30 = ord.getN43();

                String c01 = " ", c02 = " ", c03 = " ", c04 = " ", c05 = " ", c06 = " ", c07 = " ", c08 = " ",
                        c09 = " ", c010 = " ", c011 = " ", c012 = " ";
                String c013 = " ", c014 = " ", c015 = " ", c016 = " ", c017 = " ", c018 = " ", c019 = " ",
                        c020 = " ", c021 = " ", c022 = " ", c023 = " ", c024 = " ";
                String c025 = " ", c026 = " ", c027 = " ", c028 = " ", c029 = " ", c030 = " ", c031 = " ",
                        c032 = " ", c033 = " ", c034 = " ";
                if (c1 != 0)
                    c01 = String.valueOf(c1);
                if (c2 != 0)
                    c02 = String.valueOf(c2);
                //    if(c3!=0) c03 = String.valueOf(c3);
                if (c4 != 0)
                    c04 = String.valueOf(c4);
                if (c5 != 0) {
                    c05 = String.valueOf(c5);
                    CanTotal += c5;
                }
                if (c8 != 0)
                    c08 = String.valueOf(c8);
                if (c9 != 0)
                    c09 = String.valueOf(c9);
                if (c10 != 0)
                    c010 = String.valueOf(c10);
                if (c11 != 0)
                    c011 = String.valueOf(c11);
                if (c12 != 0)
                    c012 = String.valueOf(c12);
                if (c13 != 0)
                    c013 = String.valueOf(c13);
                if (c14 != 0)
                    c014 = String.valueOf(c14);
                if (c15 != 0)
                    c015 = String.valueOf(c15);
                if (c16 != 0)
                    c016 = String.valueOf(c16);
                if (c17 != 0)
                    c017 = String.valueOf(c17);
                if (c18 != 0)
                    c018 = String.valueOf(c18);
                if (c19 != 0)
                    c019 = String.valueOf(c19);
                if (c20 != 0)
                    c020 = String.valueOf(c20);
                if (c21 != 0)
                    c021 = String.valueOf(c21);
                if (c22 != 0)
                    c022 = String.valueOf(c22);
                if (c23 != 0)
                    c023 = String.valueOf(c23);
                if (c24 != 0)
                    c024 = String.valueOf(c24);
                if (c25 != 0)
                    c025 = String.valueOf(c25);
                if (c26 != 0)
                    c026 = String.valueOf(c26);
                if (c27 != 0)
                    c027 = String.valueOf(c27);
                if (c28 != 0)
                    c028 = String.valueOf(c28);
                if (c29 != 0)
                    c029 = String.valueOf(c29);
                if (c30 != 0)
                    c030 = String.valueOf(c30);

                cell = new PdfPCell(new Phrase(String.valueOf(tiq)));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(2);
                cell.setRowspan(1);
                table.addCell(cell);

                cell = new PdfPCell(new Phrase(c04));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(2);
                cell.setRowspan(1);
                table.addCell(cell);

                cell = new PdfPCell(new Phrase(c05));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(2);
                cell.setRowspan(1);
                table.addCell(cell);

                cell = new PdfPCell(new Phrase(c08));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c09));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c010));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c011));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c012));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c013));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c014));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c015));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c016));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c017));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c018));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c019));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c020));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c021));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c022));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c023));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c024));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c025));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c026));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c027));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c028));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c029));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c030));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);

                colorUno = verColor.consultarNombreColorUno(ord.getIdcoloruno());
                colorDos = verColor.consultarNombreColorDos(ord.getIdcolordos());
                //  ob = verTiquet.ConsultaObservacion(tiquet);
                Chunk ValCol1 = new Chunk(colorUno,
                        FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK));
                Chunk ValCol2 = new Chunk(colorDos,
                        FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK));
                Chunk ValObserv = new Chunk(ord.getObservacion(),
                        FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK));

                cell = new PdfPCell(new Phrase(ValCol1));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(3);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(ValCol2));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(3);
                cell.setRowspan(1);
                table.addCell(cell);

                cell = new PdfPCell(new Phrase(ValObserv));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(5);
                cell.setRowspan(1);
                table.addCell(cell);

            }

        }
        cell = new PdfPCell(new Phrase("Cantidad Total de Pares Producidos "));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(15);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(String.valueOf(CanTotal)));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(25);
        cell.setRowspan(1);
        table.addCell(cell);

        table.setWidthPercentage(95f);
        table.setHorizontalAlignment(Element.ALIGN_CENTER);
        document.add(table);

        document.close();

        return true;
    } catch (Exception x) {
        return false;
    }

}

From source file:modelo.impOrdenLegal.java

public boolean impOrden(int idOrden, String codOrden, int numRegTiq) {
    try {/*from  w  w  w .j  av  a  2 s . c  o m*/

        int id = 0;
        int numTiquet = 0;
        String ob = "";
        colores verColor = new colores();
        String colorUno = "";
        String colorDos = "";
        ArrayList<String> lista = new ArrayList<String>();
        int c1 = 0, c2 = 0, c3 = 0, c4 = 0, c5 = 0, c6 = 0, c7 = 0, c8 = 0, c9 = 0, c10 = 0, c11 = 0, c12 = 0,
                c13 = 0, c14 = 0, c15 = 0;
        int c16 = 0, c17 = 0, c18 = 0, c19 = 0, c20 = 0, c21 = 0, c22 = 0, c23 = 0, c24 = 0, c25 = 0, c26 = 0,
                c27 = 0, c28 = 0, c29 = 0;
        int c30 = 0, c31 = 0, c32 = 0, c33 = 0;
        String observacion = "";
        int CanTotal = 0;

        int idCliente = 0;
        String ciu = "";
        String fecped = "";
        String fecent = "";

        for (orden ord : new orden().CargarDatosOrden(codOrden)) {
            idCliente = ord.getCliente();
            ciu = ord.getCiudad();
            fecped = ord.getPedido();
            fecent = ord.getEntrega();
        }
        String nomCliente = nuevaOrden.ConsultarNombreCliente(idCliente);

        Chunk idClient = new Chunk(nomCliente,
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk direccion = new Chunk("Calle 12 # 6-68 Nia Ceci",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 12, Font.NORMAL, BaseColor.BLACK));
        Chunk Tiq = new Chunk("TK",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValTiq = new Chunk("",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Tel = new Chunk("Tel: 5783364",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 12, Font.NORMAL, BaseColor.BLACK));
        Chunk Ref = new Chunk("REF",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValRef = new Chunk("",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Correo = new Chunk("calzadoseiya@gmail.com",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 12, Font.NORMAL, BaseColor.BLACK));
        Chunk Cliente = new Chunk("CLIENTE",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk FecEnt = new Chunk("FECHA ENTREGA",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValFecEnt = new Chunk(fecent,
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk FecPed = new Chunk("FECHA PEDIDO",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValFecPed = new Chunk(fecped,
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk FechaTiq2 = new Chunk("",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Orden = new Chunk("ORDEN",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValOrd = new Chunk("",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Ciudad = new Chunk("CIUDAD",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValCiudad = new Chunk(ciu,
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Cant = new Chunk("CANT.",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Cor = new Chunk("CORT",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk Guar = new Chunk("GUAR",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk Mon = new Chunk("MONT",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk Emp = new Chunk("EMP",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK));
        Chunk OBSER = new Chunk("OBSERVACION",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Col1 = new Chunk("Color 1",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK));
        Chunk Col2 = new Chunk("Color 2",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK));
        Chunk Encabezado = new Chunk("SEIYA",
                FontFactory.getFont(FontFactory.HELVETICA_BOLD, 11, Font.NORMAL, BaseColor.BLACK));
        Chunk num21 = new Chunk("21",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num22 = new Chunk("22",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num23 = new Chunk("23",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num24 = new Chunk("24",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num25 = new Chunk("25",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num26 = new Chunk("26",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num27 = new Chunk("27",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num28 = new Chunk("28",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num29 = new Chunk("29",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num30 = new Chunk("30",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num31 = new Chunk("31",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num32 = new Chunk("32",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num33 = new Chunk("33",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num34 = new Chunk("34",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num35 = new Chunk("35",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num36 = new Chunk("36",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num37 = new Chunk("37",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num38 = new Chunk("38",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num39 = new Chunk("39",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num40 = new Chunk("40",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num41 = new Chunk("41",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num42 = new Chunk("42",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num43 = new Chunk("43",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num44 = new Chunk("44",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));

        File folder = new File("c:\\seiya\\ordenes");
        folder.mkdirs();
        String dir = "C:\\seiya\\ordenes\\Orden_Legal_" + codOrden + ".pdf";
        // El archivo pdf que vamos a generar
        FileOutputStream fileOutputStream = new FileOutputStream(dir);
        Rectangle pageSize = new Rectangle(1008f, 612f);

        Document document = new Document(pageSize, 1, 1, 1, 1);
        PdfWriter writer = PdfWriter.getInstance(document, fileOutputStream);
        document.open();

        PdfPTable table = new PdfPTable(50);
        PdfPCell cell = new PdfPCell();

        Image image = Image.getInstance("logo.png");
        //    String col = "jhon";
        cell = new PdfPCell(image);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(7);
        cell.setRowspan(7);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(direccion));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(43);
        cell.setRowspan(2);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Tel));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(43);
        cell.setRowspan(2);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Correo));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(43);
        cell.setRowspan(2);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(" "));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(43);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Tiq));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Orden));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(codOrden));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Cliente));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(idClient));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(12);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Ciudad));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(ValCiudad));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(4);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(FecPed));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(ValFecPed));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(4);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(FecEnt));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(ValFecEnt));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(4);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("ETAPA DEL PROCESO"));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(8);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(""));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Ref));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Cant));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        table.addCell(new Phrase(num21));
        table.addCell(new Phrase(num22));
        table.addCell(new Phrase(num23));
        table.addCell(new Phrase(num24));
        table.addCell(new Phrase(num25));
        table.addCell(new Phrase(num26));
        table.addCell(new Phrase(num27));
        table.addCell(new Phrase(num28));
        table.addCell(new Phrase(num29));
        table.addCell(new Phrase(num30));
        table.addCell(new Phrase(num31));
        table.addCell(new Phrase(num32));
        table.addCell(new Phrase(num33));
        table.addCell(new Phrase(num34));
        table.addCell(new Phrase(num35));
        table.addCell(new Phrase(num36));
        table.addCell(new Phrase(num37));
        table.addCell(new Phrase(num38));
        table.addCell(new Phrase(num39));
        table.addCell(new Phrase(num40));
        table.addCell(new Phrase(num41));
        table.addCell(new Phrase(num42));
        table.addCell(new Phrase(num43));

        cell = new PdfPCell(new Phrase(Col1));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Col2));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(OBSER));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(8);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Cor));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Guar));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Mon));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Emp));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        ArrayList<String> resultat;
        resultat = nuevoTiquet.consultarTiquetporOrden(idOrden);
        Iterator<String> tiquetIterator = resultat.iterator();

        while (tiquetIterator.hasNext()) {

            String valorTiquet = tiquetIterator.next();
            System.out.print(valorTiquet + " ------ ");
            int tiq = Integer.parseInt(valorTiquet);
            ArrayList<tiquet> listaDatosTiquet;
            listaDatosTiquet = nuevoTiquet.conten(idOrden, tiq);//La consulta tiene que retornar un ArrayList

            for (tiquet ord : new tiquet().conten(idOrden, tiq)) {
                System.out.print("Referencia: " + nuevoTiquet.ConsultarReferencia(tiq, idOrden));
                c1 = ord.getTiquet();
                c2 = ord.getIdorden();
                observacion = ord.getObservacion();
                c4 = nuevoTiquet.ConsultarReferencia(tiq, idOrden);
                c5 = nuevoTiquet.ConsultarCantidad(tiq, idOrden);
                c8 = ord.getN21();
                c9 = ord.getN22();
                c10 = ord.getN23();
                c11 = ord.getN24();
                c12 = ord.getN25();
                c13 = ord.getN26();
                c14 = ord.getN27();
                c15 = ord.getN28();
                c16 = ord.getN29();
                c17 = ord.getN30();
                c18 = ord.getN31();
                c19 = ord.getN32();
                c20 = ord.getN33();
                c21 = ord.getN34();
                c22 = ord.getN35();
                c23 = ord.getN36();
                c24 = ord.getN37();
                c25 = ord.getN38();
                c26 = ord.getN39();
                c27 = ord.getN40();
                c28 = ord.getN41();
                c29 = ord.getN42();
                c30 = ord.getN43();

                String c01 = " ", c02 = " ", c03 = " ", c04 = " ", c05 = " ", c06 = " ", c07 = " ", c08 = " ",
                        c09 = " ", c010 = " ", c011 = " ", c012 = " ";
                String c013 = " ", c014 = " ", c015 = " ", c016 = " ", c017 = " ", c018 = " ", c019 = " ",
                        c020 = " ", c021 = " ", c022 = " ", c023 = " ", c024 = " ";
                String c025 = " ", c026 = " ", c027 = " ", c028 = " ", c029 = " ", c030 = " ", c031 = " ",
                        c032 = " ", c033 = " ", c034 = " ";
                if (c1 != 0)
                    c01 = String.valueOf(c1);
                if (c2 != 0)
                    c02 = String.valueOf(c2);
                //    if(c3!=0) c03 = String.valueOf(c3);
                if (c4 != 0)
                    c04 = String.valueOf(c4);
                if (c5 != 0) {
                    c05 = String.valueOf(c5);
                    CanTotal += c5;
                }
                if (c8 != 0)
                    c08 = String.valueOf(c8);
                if (c9 != 0)
                    c09 = String.valueOf(c9);
                if (c10 != 0)
                    c010 = String.valueOf(c10);
                if (c11 != 0)
                    c011 = String.valueOf(c11);
                if (c12 != 0)
                    c012 = String.valueOf(c12);
                if (c13 != 0)
                    c013 = String.valueOf(c13);
                if (c14 != 0)
                    c014 = String.valueOf(c14);
                if (c15 != 0)
                    c015 = String.valueOf(c15);
                if (c16 != 0)
                    c016 = String.valueOf(c16);
                if (c17 != 0)
                    c017 = String.valueOf(c17);
                if (c18 != 0)
                    c018 = String.valueOf(c18);
                if (c19 != 0)
                    c019 = String.valueOf(c19);
                if (c20 != 0)
                    c020 = String.valueOf(c20);
                if (c21 != 0)
                    c021 = String.valueOf(c21);
                if (c22 != 0)
                    c022 = String.valueOf(c22);
                if (c23 != 0)
                    c023 = String.valueOf(c23);
                if (c24 != 0)
                    c024 = String.valueOf(c24);
                if (c25 != 0)
                    c025 = String.valueOf(c25);
                if (c26 != 0)
                    c026 = String.valueOf(c26);
                if (c27 != 0)
                    c027 = String.valueOf(c27);
                if (c28 != 0)
                    c028 = String.valueOf(c28);
                if (c29 != 0)
                    c029 = String.valueOf(c29);
                if (c30 != 0)
                    c030 = String.valueOf(c30);

                cell = new PdfPCell(new Phrase(String.valueOf(tiq)));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(2);
                cell.setRowspan(1);
                table.addCell(cell);

                cell = new PdfPCell(new Phrase(c04));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(2);
                cell.setRowspan(1);
                table.addCell(cell);

                cell = new PdfPCell(new Phrase(c05));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(2);
                cell.setRowspan(1);
                table.addCell(cell);

                cell = new PdfPCell(new Phrase(c08));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c09));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c010));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c011));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c012));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c013));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c014));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c015));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c016));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c017));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c018));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c019));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c020));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c021));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c022));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c023));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c024));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c025));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c026));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c027));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c028));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c029));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c030));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);

                colorUno = verColor.consultarNombreColorUno(ord.getIdcoloruno());
                colorDos = verColor.consultarNombreColorDos(ord.getIdcolordos());
                //  ob = verTiquet.ConsultaObservacion(tiquet);
                Chunk ValCol1 = new Chunk(colorUno,
                        FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK));
                Chunk ValCol2 = new Chunk(colorDos,
                        FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK));
                Chunk ValObserv = new Chunk(ord.getObservacion(),
                        FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK));

                cell = new PdfPCell(new Phrase(ValCol1));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(3);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(ValCol2));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(3);
                cell.setRowspan(1);
                table.addCell(cell);

                cell = new PdfPCell(new Phrase(ValObserv));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(8);
                cell.setRowspan(1);
                table.addCell(cell);

                cell = new PdfPCell(new Phrase(" "));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(2);
                cell.setRowspan(1);
                table.addCell(cell);

                cell = new PdfPCell(new Phrase(" "));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(2);
                cell.setRowspan(1);
                table.addCell(cell);

                cell = new PdfPCell(new Phrase(" "));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(2);
                cell.setRowspan(1);
                table.addCell(cell);

                cell = new PdfPCell(new Phrase(" "));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(2);
                cell.setRowspan(1);
                table.addCell(cell);

            }

        }
        cell = new PdfPCell(new Phrase("Cantidad Total de Pares Producidos "));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(15);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(String.valueOf(CanTotal)));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(35);
        cell.setRowspan(1);
        table.addCell(cell);

        table.setWidthPercentage(95f);
        table.setHorizontalAlignment(Element.ALIGN_CENTER);
        document.add(table);

        document.close();

        return true;
    } catch (Exception x) {
        return false;
    }

}