public void generatePdf() {

    java.lang.Process wait_for_Pdf2Show;

    java.util.Calendar cal = java.util.Calendar.getInstance();

    java.util.Date dateStampPdf = cal.getTime();

    java.lang.String pdfDateStamp = dateStampPdf.toString();

    try {

      java.io.File tempFile =
          java.io.File.createTempFile("REP" + this.getDateLable() + "_", ".pdf");

      tempFile.deleteOnExit();

      java.lang.Runtime rt = java.lang.Runtime.getRuntime();

      java.lang.String debitTotal = null;

      java.lang.String creditTotal = null;

      com.lowagie.text.Document docPdf = new com.lowagie.text.Document(PageSize.A2.rotate());

      try {

        try {
          Image img = Image.getInstance(com.afrisoftech.lib.CompanyLogo.getPath2Logo());

          // Image imgWaterMark = Image.getInstance(System.getProperty("company.watermark"));

          com.lowagie.text.pdf.PdfWriter.getInstance(
              docPdf, new java.io.FileOutputStream(tempFile));

          String compName = null;

          String District = null;

          String Region = null;

          String date = null;

          try {
            java.sql.Statement st3 = connectDB.createStatement();
            java.sql.Statement st4 = connectDB.createStatement();

            java.sql.ResultSet rset2 =
                st3.executeQuery("SELECT hospital_name,district_branch from pb_hospitalprofile");
            java.sql.ResultSet rset4 = st4.executeQuery("SELECT date('now') as Date");
            while (rset2.next()) {
              compName = rset2.getObject(1).toString();
              District = rset2.getObject(2).toString();
            }
            while (rset4.next()) {
              date = rset4.getObject(1).toString();
            }
            com.lowagie.text.HeaderFooter headerFoter =
                new com.lowagie.text.HeaderFooter(
                    new Phrase("MINISTRY OF HEALTH : " + compName.toUpperCase()),
                    false); // FontFactory.getFont(com.lowagie.text.FontFactory.HELVETICA, 14,
            // Font.BOLDITALIC,java.awt.Color.blue)));

            headerFoter.setAlignment(com.lowagie.text.HeaderFooter.ALIGN_CENTER);

            headerFoter.setRight(5);

            docPdf.setHeader(headerFoter);

          } catch (java.sql.SQLException SqlExec) {

            SqlExec.printStackTrace();

            javax.swing.JOptionPane.showMessageDialog(
                new javax.swing.JFrame(), SqlExec.getMessage());
          }

          com.lowagie.text.HeaderFooter footer =
              new com.lowagie.text.HeaderFooter(
                  new Phrase("MOH - 204B : OP Over 5 Yrs Register : Page: "),
                  true); // FontFactory.getFont(com.lowagie.text.FontFactory.HELVETICA, 12,
          // Font.BOLDITALIC,java.awt.Color.blue));

          docPdf.setFooter(footer);

          docPdf.open();

          try {

            com.lowagie.text.pdf.PdfPTable table = new com.lowagie.text.pdf.PdfPTable(21);

            int headerwidths[] = {
              5, 10, 10, 10, 25, 10, 12, 20, 12, 12, 12, 12, 12, 12, 12, 25, 25, 12, 12, 12, 25
            };

            table.setWidths(headerwidths);

            table.setWidthPercentage((100));

            table.setHeaderRows(4);

            Phrase phrase = new Phrase("", pFontHeader);

            try {

              java.text.DateFormat dateFormat =
                  java.text.DateFormat.getDateInstance(java.text.DateFormat.MEDIUM); // MEDIUM);

              java.util.Date endDate1 =
                  dateFormat.parse(endDate.toLocaleString()); // dateInstance.toLocaleString());

              java.util.Date endDate11 =
                  dateFormat.parse(beginDate.toLocaleString()); // dateInstance.toLocaleString());

              com.afrisoftech.lib.DateFormatter dateFormatter =
                  new com.afrisoftech.lib.DateFormatter(
                      dateFormat.parse(endDate.toLocaleString()), "MMMM");

              java.lang.String monthString = dateFormatter.getDateString();

              com.afrisoftech.lib.DateFormatter dateFormatters =
                  new com.afrisoftech.lib.DateFormatter(
                      dateFormat.parse(endDate.toLocaleString()), "yyyy");

              java.lang.String yearString = dateFormatters.getDateString();

              table.getDefaultCell().setBorderColor(java.awt.Color.WHITE);
              table.getDefaultCell().setColspan(21);

              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              table.getDefaultCell().setFixedHeight(50);
              table.addCell(Image.getInstance(com.afrisoftech.lib.CompanyLogo.getPath2Logo()));
              table.getDefaultCell().setFixedHeight(-1);
              // table.getDefaultCell().setNoWrap(false);
              phrase = new Phrase("MOH 204B_Over 5 Yrs Register", pFontHeader2);

              table.addCell(phrase);

              table.getDefaultCell().setColspan(5);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);

              phrase = new Phrase("OP OVER 5 YEARS REGISTER", pFontHeader22);
              table.addCell(phrase);

              table.getDefaultCell().setColspan(10);
              phrase = new Phrase("HEALTH FACILITY : " + compName, pFontHeader22);
              table.addCell(phrase);

              table.getDefaultCell().setColspan(3);
              phrase = new Phrase("MONTH : " + monthString.toUpperCase(), pFontHeader22);
              table.addCell(phrase);

              table.getDefaultCell().setColspan(3);
              phrase = new Phrase("YEAR : " + yearString.toUpperCase(), pFontHeader22);
              table.addCell(phrase);

              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);

              table.getDefaultCell().setColspan(1);

              table.getDefaultCell().setBorderColor(java.awt.Color.BLACK);

              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);

              table.getDefaultCell().setColspan(1);

              phrase = new Phrase("#", pFontHeader11);

              table.addCell(phrase);

              phrase = new Phrase("Date", pFontHeader11);
              table.addCell(phrase);

              phrase = new Phrase("OPD No.", pFontHeader11);
              table.addCell(phrase);

              phrase = new Phrase("Revisit", pFontHeader11);
              table.addCell(phrase);

              phrase = new Phrase("Full Names", pFontHeader11);
              table.addCell(phrase);

              phrase = new Phrase("Age YRS", pFontHeader11);
              table.addCell(phrase);

              phrase = new Phrase("Sex", pFontHeader11);
              table.addCell(phrase);

              phrase = new Phrase("Village", pFontHeader11);
              table.addCell(phrase);

              phrase = new Phrase("Phone. No.", pFontHeader11);
              table.addCell(phrase);

              phrase = new Phrase("Weight", pFontHeader11);
              table.addCell(phrase);

              phrase = new Phrase("Height", pFontHeader11);
              table.addCell(phrase);

              phrase = new Phrase("Visual Activity RE(Right Eye), LE(LEFT EYE)", pFontHeader11);
              table.addCell(phrase);

              phrase = new Phrase("HIV: 1=Cancelled, 2=Tested", pFontHeader11);
              table.addCell(phrase);

              phrase =
                  new Phrase(
                      "HIV Status: 1=Known Positive, 2=Positive this visit, 3=Negative, 4=Uknown",
                      pFontHeader11);
              table.addCell(phrase);

              phrase =
                  new Phrase(
                      "Nutrition Status: 1=Nutrition Education, 2=Nutrition Suppliments",
                      pFontHeader11);
              table.addCell(phrase);

              phrase = new Phrase("Diagnosis/Classification", pFontHeader11);
              table.addCell(phrase);

              phrase = new Phrase("Treatment/Prescription No.", pFontHeader11);
              table.addCell(phrase);

              phrase = new Phrase("Amount Charged", pFontHeader11);
              table.addCell(phrase);

              phrase = new Phrase("Receipt No.", pFontHeader11);
              table.addCell(phrase);

              phrase =
                  new Phrase(
                      "1 = From Other HF, 2 = To Other HF, 3 = From CU, 4 = To CU", pFontHeader11);
              table.addCell(phrase);

              phrase = new Phrase("Remarks", pFontHeader11);
              table.addCell(phrase);

              // Second header row

              phrase = new Phrase("", pFontHeader11);
              table.addCell(phrase);

              phrase = new Phrase("A", pFontHeader11);
              table.addCell(phrase);

              phrase = new Phrase("B", pFontHeader11);
              table.addCell(phrase);

              phrase = new Phrase("C", pFontHeader11);
              table.addCell(phrase);

              phrase = new Phrase("D", pFontHeader11);
              table.addCell(phrase);

              phrase = new Phrase("E", pFontHeader11);
              table.addCell(phrase);

              phrase = new Phrase("F", pFontHeader11);
              table.addCell(phrase);

              phrase = new Phrase("G", pFontHeader11);
              table.addCell(phrase);

              phrase = new Phrase("H", pFontHeader11);
              table.addCell(phrase);

              phrase = new Phrase("I", pFontHeader11);
              table.addCell(phrase);

              phrase = new Phrase("J", pFontHeader11);
              table.addCell(phrase);

              phrase = new Phrase("K", pFontHeader11);
              table.addCell(phrase);

              phrase = new Phrase("L", pFontHeader11);
              table.addCell(phrase);

              phrase = new Phrase("M", pFontHeader11);
              table.addCell(phrase);

              phrase = new Phrase("N", pFontHeader11);
              table.addCell(phrase);

              phrase = new Phrase("O", pFontHeader11);
              table.addCell(phrase);

              phrase = new Phrase("P", pFontHeader11);
              table.addCell(phrase);

              phrase = new Phrase("Q", pFontHeader11);
              table.addCell(phrase);

              phrase = new Phrase("R", pFontHeader11);
              table.addCell(phrase);

              phrase = new Phrase("S", pFontHeader11);
              table.addCell(phrase);

              phrase = new Phrase("T", pFontHeader11);
              table.addCell(phrase);

            } catch (java.text.ParseException psExec) {

              psExec.printStackTrace();

              javax.swing.JOptionPane.showMessageDialog(
                  new javax.swing.JFrame(), psExec.getMessage());
            }

            table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT);

            table.getDefaultCell().setBackgroundColor(java.awt.Color.WHITE);

            try {

              int noSeq = 0;

              java.lang.Object[] listofAct = this.getListofStaffNos();

              System.out.println("The array has been called...");

              for (int i = 0; i < listofAct.length; i++) {

                java.sql.PreparedStatement stw =
                    connectDB.prepareStatement(
                        "SELECT DISTINCT "
                            + " date_part('day', date) ||'-'||date_part('month', date) ||'-'||date_part('year', date), patient_no,"
                            + " (CASE WHEN comments = 'Old' THEN 'YES' ELSE 'NO' END) as revisit, "
                            + " initcap(name), age::int, (SELECT initcap(gender) FROM hp_patient_register WHERE hp_patient_register.patient_no = hp_patient_visit.patient_no ORDER BY 1 DESC LIMIT 1) as gender, "
                            + " (SELECT initcap(residence) FROM hp_inpatient_register"
                            + " WHERE hp_patient_visit.patient_no = hp_inpatient_register.patient_no"
                            + " UNION SELECT initcap(residence) FROM hp_patient_register WHERE "
                            + " hp_patient_visit.patient_no = hp_patient_register.patient_no ORDER BY 1 "
                            + " DESC LIMIT 1) as village, (SELECT tel_no FROM hp_patient_register WHERE hp_patient_register.patient_no = hp_patient_visit.patient_no "
                            + " ORDER BY 1 DESC LIMIT 1) as telephone, (SELECT weight::numeric(5,1) FROM hp_signs_record WHERE hp_signs_record.patient_no = hp_patient_visit.patient_no  AND hp_signs_record.date = hp_patient_visit.date ORDER BY 1 DESC LIMIT 1) as weight,"
                            + " (SELECT height::numeric(5,1) FROM hp_signs_record WHERE hp_signs_record.patient_no = hp_patient_visit.patient_no AND hp_signs_record.date = hp_patient_visit.date  ORDER BY 1 DESC LIMIT 1) as height, "
                            + " ''," // to add eye conditions for over 5 years
                            + " (SELECT (CASE WHEN hiv_counselled = true THEN '1' ELSE '' END) || ' '||"
                            + "(CASE WHEN hiv_tested = true THEN '2' ELSE '' END) FROM key_health_indicators"
                            + " WHERE key_health_indicators.patient_no = hp_patient_visit.patient_no) as hiv_tested,"
                            + " (SELECT (CASE WHEN hiv_status ilike '%positive%' THEN '1' ELSE '' END) || ' '||"
                            + "(CASE WHEN hiv_status ilike '%visit' THEN '2' ELSE '' END)||' '||"
                            + "(CASE WHEN hiv_status ilike 'negative' THEN '3' ELSE '' END)||' '||"
                            + "(CASE WHEN hiv_status ilike 'unknown' THEN '4' ELSE '' END) FROM key_health_indicators"
                            + " WHERE key_health_indicators.patient_no = hp_patient_visit.patient_no) as hiv_status,"
                            + " (SELECT (CASE WHEN nutrition_status ilike '%education%' THEN '1' ELSE '' END)||' '||"
                            + "(CASE WHEN nutrition_status ILIKE '%suppliments%' THEN '2' ELSE '' END) "
                            + "FROM key_health_indicators WHERE key_health_indicators.patient_no = hp_patient_visit.patient_no)"
                            + " as nutrition_status, "
                            + " (SELECT disease FROM hp_patient_diagnosis WHERE hp_patient_diagnosis.patient_no = hp_patient_visit.patient_no AND"
                            + " hp_patient_diagnosis.date_recorded::date = hp_patient_visit.date::date AND disease is not null ORDER BY 1 DESC LIMIT 1) as diagnosis, "
                            + " (SELECT replace(treatment, 'null', '') FROM hp_clinical_results WHERE hp_clinical_results.patient_no ="
                            + " hp_patient_visit.patient_no AND hp_clinical_results.date = hp_patient_visit.date "
                            + "ORDER BY 1 DESC LIMIT 1) as treatment, "
                            + " (SELECT sum(credit-debit) FROM ac_ledger WHERE ac_ledger.patient_no = "
                            + "hp_patient_visit.patient_no AND ac_ledger.date = hp_patient_visit.date) "
                            + "as amount, '', "
                            + " (SELECT refer_source FROM hp_patient_register WHERE hp_patient_register.patient_no"
                            + " = hp_patient_visit.patient_no AND hp_patient_register.date = hp_patient_visit.date"
                            + " ORDER BY 1 DESC LIMIT 1) as referral,"
                            + " (SELECT comments FROM hp_clinical_results WHERE hp_clinical_results.patient_no "
                            + "= hp_patient_visit.patient_no AND hp_clinical_results.date = hp_patient_visit.date"
                            + " ORDER BY 1 DESC LIMIT 1 )as comments FROM hp_patient_visit WHERE "
                            + " date::date BETWEEN '"
                            + beginDate
                            + "' AND '"
                            + endDate
                            + "' "
                            + " AND patient_no = ?");

                stw.setObject(1, listofAct[i]);

                java.sql.ResultSet rsetw = stw.executeQuery();

                while (rsetw.next()) {

                  table.getDefaultCell().setColspan(1);

                  table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);

                  table.getDefaultCell().setColspan(1);
                  noSeq = noSeq + 1;
                  // Index
                  phrase = new Phrase(java.lang.String.valueOf(noSeq), pFontHeader1);
                  table.addCell(phrase);
                  // Lab procedure date
                  phrase =
                      new Phrase(
                          new com.afrisoftech.lib.DBObject().getDBObject(rsetw.getString(1), ""),
                          pFontHeader1);
                  table.addCell(phrase);
                  // Patient Number
                  phrase =
                      new Phrase(
                          new com.afrisoftech.lib.DBObject().getDBObject(rsetw.getString(2), ""),
                          pFontHeader1);
                  table.addCell(phrase);
                  // Lab Number
                  phrase =
                      new Phrase(
                          new com.afrisoftech.lib.DBObject().getDBObject(rsetw.getString(3), ""),
                          pFontHeader1);
                  table.addCell(phrase);
                  // Revisit No
                  phrase =
                      new Phrase(
                          new com.afrisoftech.lib.DBObject().getDBObject(rsetw.getString(4), ""),
                          pFontHeader1);
                  table.addCell(phrase);
                  // Patient names
                  phrase =
                      new Phrase(
                          new com.afrisoftech.lib.DBObject().getDBObject(rsetw.getString(5), ""),
                          pFontHeader1);
                  table.addCell(phrase);
                  // Age
                  phrase =
                      new Phrase(
                          new com.afrisoftech.lib.DBObject().getDBObject(rsetw.getString(6), ""),
                          pFontHeader1);
                  table.addCell(phrase);
                  // Gender
                  phrase =
                      new Phrase(
                          new com.afrisoftech.lib.DBObject().getDBObject(rsetw.getString(7), ""),
                          pFontHeader1);
                  table.addCell(phrase);

                  // Village
                  phrase =
                      new Phrase(
                          new com.afrisoftech.lib.DBObject().getDBObject(rsetw.getString(8), ""),
                          pFontHeader1);
                  table.addCell(phrase);
                  // Telephone number
                  phrase =
                      new Phrase(
                          new com.afrisoftech.lib.DBObject().getDBObject(rsetw.getString(9), ""),
                          pFontHeader1);
                  table.addCell(phrase);
                  // Clinical diagnosis
                  phrase =
                      new Phrase(
                          new com.afrisoftech.lib.DBObject().getDBObject(rsetw.getString(10), ""),
                          pFontHeader1);
                  table.addCell(phrase);
                  // Prior treatment
                  phrase =
                      new Phrase(
                          new com.afrisoftech.lib.DBObject().getDBObject(rsetw.getString(11), ""),
                          pFontHeader1);
                  table.addCell(phrase);
                  // Type of specimen
                  phrase =
                      new Phrase(
                          new com.afrisoftech.lib.DBObject().getDBObject(rsetw.getString(12), ""),
                          pFontHeader1);
                  table.addCell(phrase);
                  // Condition of specimen
                  phrase =
                      new Phrase(
                          new com.afrisoftech.lib.DBObject().getDBObject(rsetw.getString(13), ""),
                          pFontHeader1);
                  table.addCell(phrase);
                  // Investigation required
                  phrase =
                      new Phrase(
                          new com.afrisoftech.lib.DBObject().getDBObject(rsetw.getString(14), ""),
                          pFontHeader1);
                  table.addCell(phrase);
                  // Date sample taken
                  phrase =
                      new Phrase(
                          new com.afrisoftech.lib.DBObject().getDBObject(rsetw.getString(15), ""),
                          pFontHeader1);
                  table.addCell(phrase);
                  // Date sample received
                  phrase =
                      new Phrase(
                          new com.afrisoftech.lib.DBObject().getDBObject(rsetw.getString(16), ""),
                          pFontHeader1);
                  table.addCell(phrase);
                  // Amount Paid by client
                  table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT);
                  phrase =
                      new Phrase(
                          new com.afrisoftech.lib.DBObject().getDBObject(rsetw.getString(17), ""),
                          pFontHeader1);
                  table.addCell(phrase);
                  // Date sample analysed
                  table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
                  phrase =
                      new Phrase(
                          new com.afrisoftech.lib.DBObject().getDBObject(rsetw.getString(18), ""),
                          pFontHeader1);
                  table.addCell(phrase);
                  // Results
                  phrase =
                      new Phrase(
                          new com.afrisoftech.lib.DBObject().getDBObject(rsetw.getString(19), ""),
                          pFontHeader1);
                  table.addCell(phrase);
                  // Date result dispatched
                  phrase =
                      new Phrase(
                          new com.afrisoftech.lib.DBObject().getDBObject(rsetw.getString(20), ""),
                          pFontHeader1);
                  table.addCell(phrase);
                }
              }

              docPdf.add(table);

            } catch (java.sql.SQLException SqlExec) {

              SqlExec.printStackTrace();

              javax.swing.JOptionPane.showMessageDialog(
                  new javax.swing.JFrame(), SqlExec.getMessage());
            }

          } catch (com.lowagie.text.BadElementException BadElExec) {

            javax.swing.JOptionPane.showMessageDialog(
                new javax.swing.JFrame(), BadElExec.getMessage());
          }

        } catch (java.io.FileNotFoundException fnfExec) {

          javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), fnfExec.getMessage());
        }
      } catch (com.lowagie.text.DocumentException lwDocexec) {

        javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), lwDocexec.getMessage());
      }

      docPdf.close();

      com.afrisoftech.lib.PDFRenderer.renderPDF(tempFile);

    } catch (java.io.IOException IOexec) {

      IOexec.printStackTrace();

      javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), IOexec.getMessage());
    }
  }
  public void generatePdf(java.lang.String memNo) {
    rangeDates = ageingSeries.getAgeingDateSeries();

    double columnTotals[] = new double[rangeDates.length];
    // java.lang.Object[][] rangeDates = periodicDates.getMonthlyDates();

    // double columnTotals[] = new double[rangeDates.length];

    java.lang.Process wait_for_Pdf2Show;

    java.util.Calendar cal = java.util.Calendar.getInstance();

    java.util.Date dateStampPdf = cal.getTime();

    java.lang.String pdfDateStamp = dateStampPdf.toString();

    int interval = 0;
    try {

      java.io.File tempFile =
          java.io.File.createTempFile("REP" + this.getDateLable() + "_", ".pdf");

      tempFile.deleteOnExit();

      java.lang.Runtime rt = java.lang.Runtime.getRuntime();

      java.lang.String debitTotal = null;

      java.lang.String creditTotal = null;

      com.lowagie.text.Document docPdf = new com.lowagie.text.Document(PageSize.A4.rotate());

      double osBalance = 0.00;
      double current = 0.00;
      try {

        try {

          com.lowagie.text.pdf.PdfWriter.getInstance(
              docPdf, new java.io.FileOutputStream(tempFile));

          String compName = null;
          String date = null;
          String Messg = null;

          docPdf.open();

          try {

            java.util.Calendar calendar = java.util.Calendar.getInstance();

            long dateNow = calendar.getTimeInMillis();

            java.sql.Date datenowSql = new java.sql.Date(dateNow);

            System.out.println(datenowSql.toString());

            //  java.lang.Object listofStaffNos[] = this.getListofStaffNos();

            com.lowagie.text.pdf.PdfPTable table1 = new com.lowagie.text.pdf.PdfPTable(7);
            //  com.lowagie.text.Table table = new com.lowagie.text.Table(7);

            // table.endHeaders();

            int headerwidths[] = {15, 15, 30, 15, 15, 15, 15};

            table1.setWidths(headerwidths);
            //  if (docPdf.getPageNumber() > 1) {
            //  table1.setHeaderRows(4);
            //  }
            table1.setWidthPercentage((100));

            table1.getDefaultCell().setBorder(Rectangle.BOTTOM);

            table1.getDefaultCell().setColspan(7);

            Phrase phrase = new Phrase();

            try {

              table1.getDefaultCell().setBorder(Rectangle.BOX);
              table1.getDefaultCell().setBorderColor(java.awt.Color.BLACK);
              table1.getDefaultCell().setColspan(2);
              table1.getDefaultCell().setFixedHeight(70);
              table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              table1.addCell(Image.getInstance(com.afrisoftech.lib.CompanyLogo.getPath2Logo()));
              table1.getDefaultCell().setFixedHeight(16);
              java.sql.PreparedStatement st321 =
                  connectDB.prepareStatement("select header_name from pb_header");
              java.sql.ResultSet rset3 = st321.executeQuery();
              table1.getDefaultCell().setBorder(Rectangle.BOX);
              table1.getDefaultCell().setBorderColor(java.awt.Color.BLACK);
              while (rset3.next()) {
                table1.getDefaultCell().setColspan(5);

                table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
                phrase = new Phrase(rset3.getObject(1).toString().toUpperCase(), pFontHeader1);
                table1.addCell(phrase);
              }

              //  table.addCell(phrase);

              table1.getDefaultCell().setColspan(1);
              table1.getDefaultCell().setBackgroundColor(java.awt.Color.WHITE);
              table1.getDefaultCell().setBorderColor(java.awt.Color.WHITE);

              //         try {
              java.sql.Statement st3 = connectDB.createStatement();
              java.sql.Statement st2x = connectDB.createStatement();

              java.sql.ResultSet rset2x =
                  st2x.executeQuery("SELECT rep_currency from pb_hospitalprofile");
              while (rset2x.next()) {
                ks = rset2x.getObject(1).toString();
              }

            } catch (java.sql.SQLException SqlExec) {

              SqlExec.printStackTrace();

              javax.swing.JOptionPane.showMessageDialog(
                  new javax.swing.JFrame(), SqlExec.getMessage());
            }
            docPdf.add(table1);
          } catch (com.lowagie.text.BadElementException BadElExec) {

            javax.swing.JOptionPane.showMessageDialog(
                new javax.swing.JFrame(), BadElExec.getMessage());
          }

          try {

            java.util.Calendar calendar = java.util.Calendar.getInstance();

            long dateNow = calendar.getTimeInMillis();

            java.sql.Date datenowSql = new java.sql.Date(dateNow);

            System.out.println(datenowSql.toString());

            //       java.lang.Object listofStaffNos[] = this.getListofStaffNos();

            com.lowagie.text.pdf.PdfPTable table = new com.lowagie.text.pdf.PdfPTable(11);
            //  com.lowagie.text.Table table = new com.lowagie.text.Table(7);

            // table.endHeaders();

            int headerwidths[] = {12, 12, 30, 10, 12, 12, 12, 12, 13, 13, 15};

            table.setWidths(headerwidths);
            //  if (docPdf.getPageNumber() > 1) {
            table.setHeaderRows(8);
            //  }
            table.setWidthPercentage((100));

            table.getDefaultCell().setBorder(Rectangle.BOTTOM);

            table.getDefaultCell().setColspan(8);

            Phrase phrase = new Phrase();

            //  table.addCell(phrase);

            table.getDefaultCell().setColspan(1);
            table.getDefaultCell().setBackgroundColor(java.awt.Color.WHITE);
            table.getDefaultCell().setBorderColor(java.awt.Color.WHITE);

            try {
              java.sql.Statement st22 = connectDB.createStatement();
              java.sql.Statement st11 = connectDB.createStatement();
              java.sql.Statement st = connectDB.createStatement();
              java.sql.Statement st1 = connectDB.createStatement();
              java.sql.Statement st2 = connectDB.createStatement();
              java.sql.Statement st3 = connectDB.createStatement();
              java.sql.Statement st4 = connectDB.createStatement();
              java.sql.Statement st41 = connectDB.createStatement();
              java.sql.Statement st5 = connectDB.createStatement();
              java.sql.ResultSet rset3 =
                  st3.executeQuery(
                      "select hospital_name,postal_code||' '||box_no||' '||town,main_telno||' '||other_telno,initcap(street),main_faxno,email,website,room_no from pb_hospitalprofile");
              java.sql.ResultSet rset4 =
                  st4.executeQuery(
                      "select scheme_name,account_no,tel_main,address from ac_schemes where account_no = '"
                          + memNo1
                          + "' ORDER BY 1 ASC");
              java.sql.ResultSet rset41 =
                  st41.executeQuery(
                      "select payer_name from ac_schemes where account_no = '"
                          + memNo1
                          + "' ORDER BY 1 ASC");
              java.sql.ResultSet rset1 =
                  st1.executeQuery(
                      "select date,admission_no, upper(item),invoice_no ||' '||receipt_no,journal_no,debit,balance-credit_bal, (select distinct f_name || ' '|| l_name from secure_menu_access where login_name = ac_debtors.user_name limit 1), reference_no from ac_debtors where account_no = '"
                          + memNo1
                          + "' AND date::date BETWEEN '"
                          + beginDate
                          + "' AND '"
                          + endDate
                          + "' and (balance > 0 or credit_bal > 0) order by date,invoice_no"); // UNION select pd.date::date,initcap(pd.scheme_staff_no), (sh.first_name||' '||sh.second_name||' '||sh.last_name) as name,pd.reference,sum(pd.credit),pd.patient_no from hp_patient_card pd,hp_inpatient_register sh where pd.patient_no = sh.patient_no and pd.isurer = '"+memNo+"' AND pd.date::date BETWEEN '"+beginDate+"' AND '"+endDate+"' and pd.credit > 0 group by pd.date::date,pd.scheme_staff_no, name,pd.reference,pd.invoice_no,pd.patient_no order by pd.invoice_no");
              java.sql.ResultSet rsetTotals2 =
                  st22.executeQuery(
                      "select sum(balance-credit_bal) from ac_debtors where account_no = '"
                          + memNo1
                          + "' AND date::date < '"
                          + beginDate
                          + "'");

              table.getDefaultCell().setBorderColor(java.awt.Color.BLACK);
              table.getDefaultCell().setBorderWidth(Rectangle.TOP | Rectangle.BOTTOM);

              table.getDefaultCell().setColspan(11);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              phrase = new Phrase("Statement of Account", pFontHeader11);
              table.addCell(phrase);

              while (rset4.next()) {
                table.getDefaultCell().setBorderColor(java.awt.Color.WHITE);
                table.getDefaultCell().setColspan(11);
                table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
                phrase = new Phrase(dbObject.getDBObject(rset4.getObject(1), "-"), pFontHeader1);
                table.addCell(phrase);

                while (rset41.next()) {
                  table.getDefaultCell().setColspan(11);

                  table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
                  phrase = new Phrase(dbObject.getDBObject(rset41.getObject(1), "-"), pFontHeader1);
                  table.addCell(phrase);
                }
                table.getDefaultCell().setColspan(11);

                table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
                phrase =
                    new Phrase(
                        "Account No : " + dbObject.getDBObject(rset4.getObject(2), "-"),
                        pFontHeader1);
                table.addCell(phrase);
                phrase =
                    new Phrase(
                        dbObject.getDBObject("Tel : " + rset4.getObject(3), "-"), pFontHeader1);
                table.addCell(phrase);
                phrase = new Phrase(dbObject.getDBObject(rset4.getObject(4), "-"), pFontHeader1);
                table.addCell(phrase);
              }
              table.getDefaultCell().setColspan(5);

              try {
                java.text.DateFormat dateFormat =
                    java.text.DateFormat.getDateInstance(java.text.DateFormat.MEDIUM); // MEDIUM);

                java.util.Date endDate1 =
                    dateFormat.parse(endDate.toLocaleString()); // dateInstance.toLocaleString());
                java.util.Date endDate11 =
                    dateFormat.parse(beginDate.toLocaleString()); // dateInstance.toLocaleString());

                System.out.println("" + endDate1);
                //  phrase = new Phrase(bank +" Report: " +dateFormat.format(formattedDate),
                // pFontHeader);

                //  table.addCell(phrase);

                phrase =
                    new Phrase(
                        "Period : "
                            + dateFormat.format(endDate11)
                            + " - "
                            + dateFormat.format(endDate1),
                        pFontHeader1);

                table.addCell(phrase);
              } catch (java.text.ParseException psExec) {

                javax.swing.JOptionPane.showMessageDialog(
                    new javax.swing.JFrame(), psExec.getMessage());
              }
              // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
              // phrase = new Phrase("Period : '"+beginDate+"' - '"+endDate+"'", pFontHeader1);
              // table.addCell(phrase);

              table.getDefaultCell().setColspan(6);

              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
              phrase = new Phrase("Date " + datenowSql, pFontHeader1);
              table.addCell(phrase);

              table.getDefaultCell().setColspan(3);

              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
              table.getDefaultCell().setBorderColor(java.awt.Color.BLACK);
              table.getDefaultCell().setBorderWidth(Rectangle.TOP);
              table.getDefaultCell().setColspan(1);
              phrase = new Phrase("Date", pFontHeader1);
              table.addCell(phrase);
              table.getDefaultCell().setColspan(1);
              phrase = new Phrase("Patient No.", pFontHeader1);
              table.addCell(phrase);
              table.getDefaultCell().setColspan(1);
              phrase = new Phrase("Name", pFontHeader1);
              table.addCell(phrase);

              table.getDefaultCell().setColspan(1);
              phrase = new Phrase("Invoice No.", pFontHeader1);
              table.addCell(phrase);
              phrase = new Phrase("Member No.", pFontHeader1);
              table.addCell(phrase);
              table.getDefaultCell().setColspan(1);
              phrase = new Phrase("Claim No..", pFontHeader1);
              table.addCell(phrase);
              phrase = new Phrase("Ward Name", pFontHeader1);
              table.addCell(phrase);
              phrase = new Phrase("Prepared By", pFontHeader1);
              table.addCell(phrase);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT);

              table.getDefaultCell().setColspan(1);
              phrase = new Phrase("Orig. Amt ", pFontHeader1);
              table.addCell(phrase);
              table.getDefaultCell().setColspan(1);
              phrase = new Phrase("Curr. Amt ", pFontHeader1);
              table.addCell(phrase);
              table.getDefaultCell().setColspan(1);
              phrase = new Phrase("Running Amt. " + ks, pFontHeader1);
              table.addCell(phrase);
              // table
              double osBalancex = 0.00;
              double osBalancex1 = 0.00;

              while (rsetTotals2.next()) {
                table.getDefaultCell().setColspan(5);

                table.getDefaultCell().setBorderColor(java.awt.Color.WHITE);

                table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
                phrase = new Phrase("BAL/BF", pFontHeader1);
                table.addCell(phrase);
                table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT);
                table.getDefaultCell().setColspan(6);
                phrase =
                    new Phrase(
                        new com.afrisoftech.sys.Format2Currency()
                            .Format2Currency(rsetTotals2.getString(1)),
                        pFontHeader1);
                osBalance = osBalance + rsetTotals2.getDouble(1);
                table.addCell(phrase);
              }
              while (rset1.next()) {
                table.getDefaultCell().setColspan(1);
                table.getDefaultCell().setBorderColor(java.awt.Color.WHITE);

                table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
                phrase = new Phrase(dbObject.getDBObject(rset1.getObject(1), "-"), pFontHeader);

                table.addCell(phrase);
                table.getDefaultCell().setColspan(1);

                table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
                phrase = new Phrase(dbObject.getDBObject(rset1.getObject(2), "-"), pFontHeader);

                table.addCell(phrase);
                table.getDefaultCell().setColspan(1);
                table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
                phrase = new Phrase(dbObject.getDBObject(rset1.getObject(3), "-"), pFontHeader);

                table.addCell(phrase);

                table.getDefaultCell().setColspan(1);
                table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
                phrase = new Phrase(dbObject.getDBObject(rset1.getObject(4), "-"), pFontHeader);

                table.addCell(phrase);
                table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
                phrase = new Phrase(dbObject.getDBObject(rset1.getObject(5), "-"), pFontHeader);

                table.addCell(phrase);
                phrase = new Phrase(dbObject.getDBObject(rset1.getObject(9), "-"), pFontHeader);

                table.addCell(phrase);

                java.sql.PreparedStatement pstmt =
                    connectDB.prepareStatement(
                        "SELECT distinct main_service from hp_patient_card where patient_no = ? AND service ilike '%daily bed%' order by main_service desc limit 1");
                pstmt.setString(1, rset1.getString(2));
                java.sql.ResultSet rsets = pstmt.executeQuery();
                String wardName = "-";
                // System.out.println("Printing visit_id number ");
                while (rsets.next()) {

                  System.out.println("Ward name = [" + rsets.getString(1) + "]");
                  wardName = rsets.getString(1);
                }
                rsets.close();
                pstmt.close();
                phrase = new Phrase(wardName, pFontHeader);
                table.addCell(phrase);

                phrase =
                    new Phrase(
                        dbObject.getDBObject(rset1.getObject(8), "-").toUpperCase(), pFontHeader);

                table.addCell(phrase);

                table.getDefaultCell().setColspan(1);
                table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT);

                phrase =
                    new Phrase(
                        new com.afrisoftech.sys.Format2Currency()
                            .Format2Currency(rset1.getString(6)),
                        pFontHeader);

                table.addCell(phrase);
                osBalancex = osBalancex + rset1.getDouble(6);
                phrase =
                    new Phrase(
                        new com.afrisoftech.sys.Format2Currency()
                            .Format2Currency(rset1.getString(7)),
                        pFontHeader);
                osBalancex1 = osBalancex1 + rset1.getDouble(7);
                osBalance = osBalance + rset1.getDouble(7);
                table.addCell(phrase);
                phrase =
                    new Phrase(
                        new com.afrisoftech.sys.Format2Currency()
                            .Format2Currency(java.lang.String.valueOf(osBalance)),
                        pFontHeader);

                table.addCell(phrase);
              }
              table.getDefaultCell().setColspan(2);

              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT);
              phrase = new Phrase("", pFontHeader);

              table.addCell(phrase);
              table.getDefaultCell().setBorderColor(java.awt.Color.BLACK);

              table.getDefaultCell().setBorder(Rectangle.BOTTOM | Rectangle.TOP);

              //  while (rsetTotals.next()) {

              table.getDefaultCell().setColspan(6);

              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
              phrase = new Phrase("Total", pFontHeader);

              table.addCell(phrase);

              table.getDefaultCell().setColspan(1);

              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT);

              phrase =
                  new Phrase(
                      new com.afrisoftech.sys.Format2Currency()
                          .Format2Currency(java.lang.String.valueOf(osBalancex)),
                      pFontHeader);

              table.addCell(phrase);

              phrase =
                  new Phrase(
                      new com.afrisoftech.sys.Format2Currency()
                          .Format2Currency(java.lang.String.valueOf(osBalancex1)),
                      pFontHeader);

              table.addCell(phrase);
              phrase =
                  new Phrase(
                      new com.afrisoftech.sys.Format2Currency()
                          .Format2Currency(java.lang.String.valueOf(osBalance)),
                      pFontHeader);

              table.addCell(phrase);

              table.getDefaultCell().setColspan(6);

              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
              phrase = new Phrase("     ''  ", pFontHeader);

              table.addCell(phrase);

              docPdf.add(table);

              double Totals = 0.00;

              try {

                com.lowagie.text.pdf.PdfPTable table12 =
                    new com.lowagie.text.pdf.PdfPTable(rangeDates.length + 4);

                String headerWidths = null;

                java.util.Vector headerVector = new java.util.Vector(1, 1);

                int z = rangeDates.length;

                int headerwidth[] = {22, 13, 13, 13, 13, 13, 13, 13}; // ,13,13};

                table12.setWidths(headerwidth);

                table12.setWidthPercentage((100));

                table12.setHeaderRows(2);

                table12.getDefaultCell().setBorder(Rectangle.BOTTOM);
                //
                table.getDefaultCell().setColspan(8);
                Phrase phraseA = new Phrase("");

                table12.getDefaultCell().setColspan(1);

                phraseA = new Phrase("AGEING DETAILS", pFontHeader1);
                table12.addCell(phraseA);

                interval = 0;
                for (int x = rangeDates.length - 1; x >= 0; x--) {
                  table12.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT);

                  try {

                    // Date parser

                    table12.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT);

                    java.text.SimpleDateFormat dateFormat =
                        new java.text.SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy");
                    com.afrisoftech.lib.DateFormatter dateFormatter =
                        new com.afrisoftech.lib.DateFormatter(
                            dateFormat.parse(rangeDates[x][0].toString().trim()), "MMM/yy");

                    java.lang.String monthString = dateFormatter.getDateString();

                    int days = 1;

                    phraseA = new Phrase(monthString, pFontHeader1);
                    table12.addCell(phraseA);

                  } catch (java.text.ParseException prs) {
                    prs.printStackTrace();
                  }

                  interval++;
                }
                phraseA = new Phrase("+ " + (interval * 30) + " Days", pFontHeader1);
                table12.addCell(phraseA);

                phraseA = new Phrase("Un Alloc.", pFontHeader1);
                table12.addCell(phraseA);

                phraseA = new Phrase("O/S " + ks, pFontHeader1);
                table12.addCell(phraseA);

                table12.getDefaultCell().setBackgroundColor(java.awt.Color.WHITE);
                table12.getDefaultCell().setBorderColor(java.awt.Color.WHITE);

                try {

                  double GrandTotal = 0.00;
                  double Over120Total = 0.00;
                  java.lang.Object[] listofAct = this.getListofActivities();

                  //    java.sql.Connection conDb1 =
                  // java.sql.DriverManager.getConnection("jdbc:postgresql://localhost:5432/sako","postgres","pilsiner");

                  System.out.println(listofAct.length);

                  //  for (int i = 0; i < listofAct.length; i++) {
                  double TurnOver = 0.00;
                  double Over120 = 0.00;
                  double TotalCount = 0.00;

                  table12.getDefaultCell().setColspan(1);
                  java.sql.Statement stmta1 = connectDB.createStatement();
                  java.sql.PreparedStatement pSeta1 =
                      connectDB.prepareStatement(
                          "SELECT count(distinct(account_no)) FROM ac_debtors where account_no IS NOT NULL and account_no ='"
                              + memNo1
                              + "'");
                  java.sql.PreparedStatement pset22 =
                      connectDB.prepareStatement(
                          "select distinct account_no||' '||scheme_name from ac_schemes WHERE account_no = '"
                              + memNo1
                              + "' "); // < '"+endDate+"'::date and date > '"+endDate+"'::date - 30
                                       // group by dealer");
                  //   pset22.setString(1,""+memNo1.toUpperCase());
                  java.sql.ResultSet rSeta1 = pSeta1.executeQuery();
                  while (rSeta1.next()) {
                    name = rSeta1.getInt(1);
                  }
                  if (name > 0) {
                    java.sql.ResultSet rset22 = pset22.executeQuery();

                    while (rset22.next()) {

                      table12.getDefaultCell().setColspan(1);
                      //     phraseA = new Phrase(dbObject.getDBObject(rset22.getObject(1),
                      // "-"),pFontHeader1);
                      phraseA = new Phrase(dbObject.getDBObject(" ", "-"), pFontHeader1);

                      table12.addCell(phraseA);
                      // columnTotals[t] = columnTotals[t] + rset.getDouble(1);

                    }
                  } else {
                    phraseA = new Phrase("-", pFontHeader1);
                    table12.addCell(phraseA);
                  }
                  // java.sql.Statement st2 = connectDB.createStatement();

                  table12.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);

                  java.sql.Statement st2B = connectDB.createStatement();
                  java.sql.Statement st21 = connectDB.createStatement();
                  java.sql.Statement st22A = connectDB.createStatement();
                  java.sql.Statement st23 = connectDB.createStatement();
                  java.sql.Statement st211 = connectDB.createStatement();
                  java.sql.Statement st221 = connectDB.createStatement();
                  java.sql.Statement st233 = connectDB.createStatement();
                  java.sql.Statement st2A = connectDB.createStatement();
                  java.sql.Statement st2B1 = connectDB.createStatement();
                  java.sql.Statement st2C = connectDB.createStatement();
                  java.sql.Statement stc = connectDB.createStatement();
                  System.out.println("Dealer Is : '" + memNo1 + "'");
                  java.sql.PreparedStatement pset1 =
                      connectDB.prepareStatement(
                          "select sum(balance) from ac_debtors WHERE account_no = '"
                              + memNo1
                              + "' AND dealer IS NOT NULL AND date < '"
                              + rangeDates[0][0]
                              + "'"); // < '"+endDate+"'::date and date > '"+endDate+"'::date - 30
                                      // group by dealer");
                  // pset1.setString(1,""+memNo1);
                  java.sql.ResultSet rset1A = pset1.executeQuery();

                  java.sql.PreparedStatement pset112 =
                      connectDB.prepareStatement(
                          "select sum(credit_bal) from ac_debtors WHERE account_no = ? AND date <= '"
                              + endDate
                              + "'"); // < '"+endDate+"'::date and date > '"+endDate+"'::date - 30
                                      // group by dealer");
                  pset112.setString(1, memNo1);
                  java.sql.ResultSet rset112 = pset112.executeQuery();

                  for (int t = rangeDates.length - 1; t >= 0; t--) {
                    java.sql.Statement st81 = connectDB.createStatement();
                    java.sql.Statement st01 = connectDB.createStatement();

                    java.sql.ResultSet rset01 =
                        st01.executeQuery(
                            "select count(balance) from ac_debtors WHERE account_no = '"
                                + memNo1
                                + "' AND dealer IS NOT NULL AND date between '"
                                + rangeDates[t][0]
                                + "' AND '"
                                + rangeDates[t][1]
                                + "'");

                    java.sql.PreparedStatement pset =
                        connectDB.prepareStatement(
                            "select sum(balance) from ac_debtors WHERE account_no = '"
                                + memNo1
                                + "' AND dealer IS NOT NULL AND date between '"
                                + rangeDates[t][0]
                                + "' AND '"
                                + rangeDates[t][1]
                                + "'"); // < '"+endDate+"'::date and date > '"+endDate+"'::date - 30
                                        // group by dealer");
                    while (rset01.next()) {
                      over = rset01.getInt(1);
                    }
                    if (t == 3) {
                      java.sql.PreparedStatement pset1x =
                          connectDB.prepareStatement(
                              "select sum(balance) from ac_debtors WHERE account_no = '"
                                  + memNo1
                                  + "' AND dealer IS NOT NULL AND date between '"
                                  + rangeDates[t][0]
                                  + "' AND '"
                                  + endDate
                                  + "'"); // < '"+endDate+"'::date and date > '"+endDate+"'::date -
                                          // 30 group by dealer");
                      System.out.print(rangeDates[t][0] + " AND " + endDate);
                      if (over > 0) {
                        //  pset.setString(1,""+memNo1.toString().toUpperCase());
                        java.sql.ResultSet rset = pset1x.executeQuery();
                        while (rset.next()) {

                          table12.getDefaultCell().setColspan(1);
                          table12.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT);
                          phraseA =
                              new Phrase(
                                  new com.afrisoftech.sys.Format2Currency()
                                      .Format2Currency(rset.getString(1)),
                                  pFontHeader1);
                          table12.addCell(phraseA);
                          columnTotals[t] = columnTotals[t] + rset.getDouble(1);

                          TotalCount = TotalCount + rset.getDouble(1);
                        }

                      } else {

                        table12.getDefaultCell().setColspan(1);
                        table12.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT);
                        phraseA =
                            new Phrase(
                                new com.afrisoftech.sys.Format2Currency().Format2Currency("0.00"),
                                pFontHeader1);
                        table12.addCell(phraseA);
                      }
                    } else {
                      if (over > 0) {
                        //  pset.setString(1,""+memNo1.toString().toUpperCase());
                        java.sql.ResultSet rset = pset.executeQuery();
                        while (rset.next()) {

                          table12.getDefaultCell().setColspan(1);
                          table12.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT);
                          phraseA =
                              new Phrase(
                                  new com.afrisoftech.sys.Format2Currency()
                                      .Format2Currency(rset.getString(1)),
                                  pFontHeader1);
                          table12.addCell(phraseA);
                          columnTotals[t] = columnTotals[t] + rset.getDouble(1);

                          TotalCount = TotalCount + rset.getDouble(1);
                        }

                      } else {

                        table12.getDefaultCell().setColspan(1);
                        table12.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT);
                        phraseA =
                            new Phrase(
                                new com.afrisoftech.sys.Format2Currency().Format2Currency("0.00"),
                                pFontHeader1);
                        table12.addCell(phraseA);
                      }
                    }
                  }

                  // GrandTotal = GrandTotal + TotalCount;
                  while (rset1A.next()) {
                    System.out.println("This Result " + rset1A.getString(1));
                    table12.getDefaultCell().setColspan(1);
                    table12.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT);
                    phraseA =
                        new Phrase(
                            new com.afrisoftech.sys.Format2Currency()
                                .Format2Currency(rset1A.getString(1)),
                            pFontHeader1);
                    Over120 = rset1A.getDouble(1);
                    table12.addCell(phraseA);
                    Over120Total = Over120Total + rset1A.getDouble(1);
                    TurnOver = TotalCount + Over120;
                  }

                  while (rset112.next()) {
                    phraseA =
                        new Phrase(
                            new com.afrisoftech.sys.Format2Currency()
                                .Format2Currency(rset112.getString(1)),
                            pFontHeader1);
                    table12.addCell(phraseA);
                    OS = OS + rset112.getDouble(1);
                  }
                  // Over120 = Over120+Over120;
                  phraseA =
                      new Phrase(
                          new com.afrisoftech.sys.Format2Currency()
                              .Format2Currency(java.lang.String.valueOf(TurnOver - OS)),
                          pFontHeader1);
                  table12.addCell(phraseA);
                  Totals = Totals + TurnOver;

                  // }

                  table12.getDefaultCell().setBorderColor(java.awt.Color.BLACK);

                  table12.getDefaultCell().setBorder(Rectangle.BOTTOM | Rectangle.TOP);

                  // while (rsetTotals.next()) {

                  table12.getDefaultCell().setColspan(1);

                  table12.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
                  phraseA = new Phrase("Total", pFontHeader);

                  table12.addCell(phraseA);

                  table12.getDefaultCell().setColspan(1);

                  table12.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT);

                  // phrase = new Phrase(new
                  // com.afrisoftech.sys.Format2Currency().Format2Currency(rsetTotals.getString(1)),
                  // pFontHeader);
                  for (int x = rangeDates.length - 1; x >= 0; x--) {
                    // phrase = new Phrase("Current"+2*x,pFontHeader);
                    // table.addCell(phrase);

                    phraseA =
                        new Phrase(
                            new com.afrisoftech.sys.Format2Currency()
                                .Format2Currency(java.lang.String.valueOf(columnTotals[x])),
                            pFontHeader);

                    table12.addCell(phraseA);
                    columnTo = columnTo + columnTotals[x];
                  }

                  phraseA =
                      new Phrase(
                          new com.afrisoftech.sys.Format2Currency()
                              .Format2Currency(java.lang.String.valueOf(Over120Total)),
                          pFontHeader);

                  table12.addCell(phraseA);

                  phraseA =
                      new Phrase(
                          new com.afrisoftech.sys.Format2Currency()
                              .Format2Currency(java.lang.String.valueOf(OS)),
                          pFontHeader);

                  table12.addCell(phraseA);

                  phraseA =
                      new Phrase(
                          new com.afrisoftech.sys.Format2Currency()
                              .Format2Currency(
                                  java.lang.String.valueOf((columnTo + Over120Total) - OS)),
                          pFontHeader);

                  table12.addCell(phraseA);

                  try {

                    java.sql.Statement st31 = connectDB.createStatement();
                    // java.sql.Statement st4 = connectDB.createStatement();
                    java.sql.ResultSet rset2 = st31.executeQuery("select name from pb_notice");

                    while (rset2.next()) {
                      Messg = rset2.getString(1);
                    }
                    com.lowagie.text.HeaderFooter footer1 =
                        new com.lowagie.text.HeaderFooter(
                            new Phrase("" + Messg + ""),
                            false); // FontFactory.getFont(com.lowagie.text.FontFactory.HELVETICA,
                                    // 14, Font.BOLDITALIC,java.awt.Color.blue)));

                    docPdf.setFooter(footer1);

                  } catch (java.sql.SQLException SqlExec) {

                    SqlExec.printStackTrace();

                    javax.swing.JOptionPane.showMessageDialog(
                        new javax.swing.JFrame(), SqlExec.getMessage());
                  }
                  docPdf.add(table12);

                } catch (java.sql.SQLException SqlExec) {

                  SqlExec.printStackTrace();

                  javax.swing.JOptionPane.showMessageDialog(
                      new javax.swing.JFrame(), SqlExec.getMessage());
                }

              } catch (com.lowagie.text.BadElementException BadElExec) {

                // Bad

                javax.swing.JOptionPane.showMessageDialog(
                    new javax.swing.JFrame(), BadElExec.getMessage());
              }

              //  docPdf.add(table);

            } catch (java.sql.SQLException SqlExec) {

              SqlExec.printStackTrace();

              javax.swing.JOptionPane.showMessageDialog(
                  new javax.swing.JFrame(), SqlExec.getMessage());
            }

            // }  // }

          } catch (com.lowagie.text.BadElementException BadElExec) {

            javax.swing.JOptionPane.showMessageDialog(
                new javax.swing.JFrame(), BadElExec.getMessage());
          }

        } catch (java.io.FileNotFoundException fnfExec) {

          javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), fnfExec.getMessage());
        }
      } catch (com.lowagie.text.DocumentException lwDocexec) {

        javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), lwDocexec.getMessage());
      }

      docPdf.close();
      docPdf.close();
      com.afrisoftech.lib.PDFRenderer.renderPDF(tempFile);

    } catch (java.io.IOException IOexec) {

      javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), IOexec.getMessage());
    }
  }
예제 #3
0
  public void generatePdf(java.lang.String memNo) {

    java.lang.Process wait_for_Pdf2Show;

    java.util.Calendar cal = java.util.Calendar.getInstance();

    java.util.Date dateStampPdf = cal.getTime();

    java.lang.String pdfDateStamp = dateStampPdf.toString();

    try {

      java.io.File tempFile =
          java.io.File.createTempFile("REP" + this.getDateLable() + "_", ".pdf");

      tempFile.deleteOnExit();

      java.lang.Runtime rt = java.lang.Runtime.getRuntime();

      java.lang.String debitTotal = null;

      java.lang.String creditTotal = null;

      int titleFont = 0;
      int bodyFont = 0;
      float Widths = 0;
      float Heights = 0;
      float Margins = 0;

      try {
        connectDB.setAutoCommit(false);

        java.sql.Statement stm1 = connectDB.createStatement();
        java.sql.ResultSet rse1 =
            stm1.executeQuery(
                "select header_font,body_font,width,height,margins from receipt_pref");
        while (rse1.next()) {
          titleFont = rse1.getInt(1);
          bodyFont = rse1.getInt(2);
          Widths = rse1.getFloat(3);
          Heights = rse1.getFloat(4);
          Margins = rse1.getFloat(5);
        }
      } catch (java.sql.SQLException sq) {

        try {
          connectDB.rollback();
        } catch (java.sql.SQLException sql) {
          //   javax.swing.JOptionPane.showMessageDialog(this,sql.getMessage(),"Error
          // Message!",javax.swing.JOptionPane.ERROR_MESSAGE);
        }
        System.out.println(sq.getMessage());
        //   javax.swing.JOptionPane.showMessageDialog(this,sq.getMessage(),
        // "Error",javax.swing.JOptionPane.ERROR_MESSAGE);

      }
      com.lowagie.text.Font pFontHeader2 =
          FontFactory.getFont(FontFactory.HELVETICA, bodyFont, Font.BOLD);

      com.lowagie.text.Font pFontHeader =
          FontFactory.getFont(FontFactory.HELVETICA, bodyFont, Font.NORMAL);
      com.lowagie.text.Font pFontHeader1 =
          FontFactory.getFont(FontFactory.HELVETICA, titleFont, Font.BOLD);
      com.lowagie.text.Font pFontHeader11 =
          FontFactory.getFont(FontFactory.TIMES_ITALIC, 8, Font.BOLD);

      // com.lowagie.text.Document docPdf = new com.lowagie.text.Document(new
      // Rectangle(java.lang.Float.parseFloat(System.getProperty("papersize_width")),
      // java.lang.Float.parseFloat(System.getProperty("papersize_legnth"))),java.lang.Float.parseFloat(System.getProperty("receiptPageMargin")),java.lang.Float.parseFloat(System.getProperty("receiptPageMargin")),java.lang.Float.parseFloat(System.getProperty("receiptPageMargin")),java.lang.Float.parseFloat(System.getProperty("receiptPageMargin")));
      ///// com.lowagie.text.Document docPdf = new com.lowagie.text.Document(new Rectangle((Widths),
      // Heights), Margins, Margins, Margins, Margins);
      com.lowagie.text.Document docPdf = new com.lowagie.text.Document(PageSize.A4.rotate());

      //            com.lowagie.text.Document docPdf = new com.lowagie.text.Document(new
      // Rectangle(java.lang.Float.parseFloat(System.getProperty("papersize_width")),
      // java.lang.Float.parseFloat(System.getProperty("papersize_legnth"))));

      try {

        try {

          com.lowagie.text.pdf.PdfWriter.getInstance(
              docPdf, new java.io.FileOutputStream(tempFile));

          String compName = null;
          String date = null;
          PdfWriter writer = PdfWriter.getInstance(docPdf, new FileOutputStream(tempFile));
          docPdf.open();
          PdfContentByte cb = writer.getDirectContent();
          String footers = null;
          try {

            com.lowagie.text.pdf.PdfPTable table = new com.lowagie.text.pdf.PdfPTable(6);

            int headerwidths[] = {15, 15, 15, 15, 15, 15};

            table.setWidths(headerwidths);

            table.setWidthPercentage((100));
            table.getDefaultCell().setColspan(6);
            table.getDefaultCell().setFixedHeight(55);
            table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
            table.addCell(Image.getInstance(com.afrisoftech.lib.CompanyLogo.getPath2Logo()));
            table.getDefaultCell().setFixedHeight(16);
            Phrase phrase = new Phrase("");

            // table.addCell(phrase);
            table.getDefaultCell().setBorderColor(java.awt.Color.WHITE);
            table.getDefaultCell().setColspan(1);
            table.getDefaultCell().setBackgroundColor(java.awt.Color.WHITE);
            table.getDefaultCell().setBorderColor(java.awt.Color.WHITE);

            try {

              String patAge = "-";

              java.sql.Statement st = connectDB.createStatement();
              java.sql.Statement st1 = connectDB.createStatement();
              java.sql.Statement st2 = connectDB.createStatement();
              java.sql.Statement st5 = connectDB.createStatement();
              java.sql.Statement st6 = connectDB.createStatement();
              java.sql.Statement st51 = connectDB.createStatement();
              java.sql.Statement st3 = connectDB.createStatement();
              java.sql.ResultSet rset3 =
                  st3.executeQuery(
                      "select hospital_name,box_no,main_telno,main_faxno from pb_hospitalprofile");

              java.sql.ResultSet rs =
                  st.executeQuery(
                      "select patient_no,patient_name,discharge_no,discharge_date,doctor, date_part('hour', discharge_time::time) ||':' || date_part('min', discharge_time::time) ||':'||round(date_part('sec', discharge_time::time)),admission_date,user_name,ward from hp_patient_discharge cb where inv_no = '"
                          + invoiceNo
                          + "'");

              System.out.println(MNo);

              while (rset3.next()) {
                table.getDefaultCell().setColspan(6);

                table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
                phrase = new Phrase(rset3.getObject(1).toString(), pFontHeader1);
                table.addCell(phrase);

                phrase = new Phrase("P.O. BOX : " + rset3.getObject(2).toString(), pFontHeader2);
                table.addCell(phrase);

                phrase =
                    new Phrase(
                        "TEL : "
                            + rset3.getObject(3).toString()
                            + "  FAX : "
                            + rset3.getObject(4).toString(),
                        pFontHeader2);
                table.addCell(phrase);
              }
              //  table.getDefaultCell().setBorderColor(java.awt.Color.BLACK);
              //  table.getDefaultCell().setBorderWidth(Rectangle.TOP);

              table.getDefaultCell().setColspan(6);
              phrase = new Phrase("PATIENT RELEASE FORM", pFontHeader1);

              table.addCell(phrase);

              java.sql.PreparedStatement pstmtHeader =
                  connectDB.prepareStatement("SELECT nextval('release_seq_no'), current_user");
              java.sql.ResultSet rsetheader = pstmtHeader.executeQuery();

              table.getDefaultCell().setColspan(2);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
              phrase = new Phrase("Form No : 501".toUpperCase(), pFontHeader2);

              table.addCell(phrase);
              while (rsetheader.next()) {
                table.getDefaultCell().setColspan(2);
                table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
                phrase =
                    new Phrase("Serial No : ".toUpperCase() + rsetheader.getInt(1), pFontHeader2);

                table.addCell(phrase);
                table.getDefaultCell().setColspan(2);
                phrase =
                    new Phrase(
                        "Printed by : ".toUpperCase() + rsetheader.getString(2).toUpperCase(),
                        pFontHeader2);

                table.addCell(phrase);
              }

              table.getDefaultCell().setColspan(2);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
              // phrase = new Phrase("Internal Claim No : ".toUpperCase(), pFontHeader);

              //  table.addCell(phrase);

              java.sql.PreparedStatement pstmtClaimNo =
                  connectDB.prepareStatement(
                      "SELECT claim_no FROM hp_patient_discharge WHERE patient_no = ?");

              pstmtClaimNo.setString(1, MNo);

              java.sql.ResultSet rsetClaimNo = pstmtClaimNo.executeQuery();

              table.getDefaultCell().setColspan(2);

              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);

              //    while (rsetClaimNo.next()) {

              //        phrase = new Phrase("Internal Claim No : " + invoiceNo, pFontHeader);

              //    }

              //  table.addCell(phrase);

              table.getDefaultCell().setColspan(2);
              String claimNumber = "";
              while (rsetClaimNo.next()) {
                claimNumber = rsetClaimNo.getString(1).toUpperCase(); /* + rsheader.getString(6)*/
              }
              System.out.println("Printing claim number : [" + claimNumber + "]");
              phrase =
                  new Phrase(
                      "NHIF Claim Number : ".toUpperCase() + claimNumber.toUpperCase(),
                      pFontHeader);
              table.addCell(phrase);

              while (rs.next()) {

                table.getDefaultCell().setColspan(2);
                table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
                phrase =
                    new Phrase(
                        "Discharge No : ".toUpperCase() + rs.getString(3).toUpperCase(),
                        pFontHeader);

                table.addCell(phrase);

                table.getDefaultCell().setColspan(2);
                table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
                phrase =
                    new Phrase(
                        "Date : ".toUpperCase() + rs.getObject(4).toString().toUpperCase(),
                        pFontHeader);

                table.addCell(phrase);
                table.getDefaultCell().setColspan(2);
                phrase =
                    new Phrase(
                        "TIME : ".toUpperCase() + rs.getString(6).toUpperCase(), pFontHeader);

                table.addCell(phrase);

                patNo = rs.getString(1);

                table.getDefaultCell().setColspan(2);
                phrase =
                    new Phrase("Patient No : ".toUpperCase() + patNo.toUpperCase(), pFontHeader);

                table.addCell(phrase);
                table.getDefaultCell().setColspan(2);
                phrase =
                    new Phrase(
                        "Patient Name : ".toUpperCase() + rs.getObject(2).toString().toUpperCase(),
                        pFontHeader);
                patientName = rs.getObject(2).toString();
                table.addCell(phrase);
                table.getDefaultCell().setColspan(2);
                java.sql.ResultSet rsw =
                    st1.executeQuery(
                        "SELECT ('now'::date-year_of_birth::date)/365 FROM hp_inpatient_register WHERE patient_no =  '"
                            + rs.getString(1)
                            + "'");
                while (rsw.next()) {
                  phrase =
                      new Phrase(
                          "Age: ".toUpperCase() + rsw.getObject(1).toString().toUpperCase(),
                          pFontHeader);

                  table.addCell(phrase);
                }
                table.getDefaultCell().setColspan(2);
                phrase =
                    new Phrase(
                        "Admission Date : ".toUpperCase() + rs.getString(7).toUpperCase(),
                        pFontHeader);

                table.addCell(phrase);

                table.getDefaultCell().setColspan(2);
                phrase =
                    new Phrase(
                        "Discharge Date : ".toUpperCase()
                            + rs.getObject(4).toString().toUpperCase(),
                        pFontHeader);

                table.addCell(phrase);
                table.getDefaultCell().setColspan(2);
                phrase =
                    new Phrase(
                        "Ward : ".toUpperCase() + rs.getObject(9).toString().toUpperCase(),
                        pFontHeader);

                table.addCell(phrase);
              }
              table.getDefaultCell().setColspan(6);
              phrase = new Phrase("  ", pFontHeader);

              table.addCell(phrase);
              phrase = new Phrase("Method of Payment(Tick where appropriate)", pFontHeader11);

              table.addCell(phrase);

              phrase =
                  new Phrase(
                      "Cash [   ] / Cheque [   ] / N.H.I.F [   ] / CO-OP [   ] / M.R.M [   ] / OTHERS.......................................................... Final Invoice No : "
                          + invoiceNo.toUpperCase(),
                      pFontHeader2);

              table.addCell(phrase);

              table.getDefaultCell().setColspan(6);
              phrase = new Phrase(" ", pFontHeader);
              table.addCell(phrase);
              table.getDefaultCell().setColspan(2);
              phrase =
                  new Phrase("Finance Clearance : ____________________".toUpperCase(), pFontHeader);
              table.addCell(phrase);

              phrase = new Phrase("Sign/Stamp: ______________________".toUpperCase(), pFontHeader);
              table.addCell(phrase);
              phrase =
                  new Phrase(
                      "Check-Out Date and Time: _____________________".toUpperCase(), pFontHeader);

              table.addCell(phrase);

              table.getDefaultCell().setColspan(6);
              phrase = new Phrase(" ", pFontHeader);
              table.addCell(phrase);
              table.getDefaultCell().setColspan(2);
              phrase =
                  new Phrase(
                      "Nurse Clearance : _______________________".toUpperCase(), pFontHeader);
              table.addCell(phrase);

              phrase = new Phrase("Sign/Stamp: ______________________".toUpperCase(), pFontHeader);
              table.addCell(phrase);
              phrase =
                  new Phrase(
                      "Check-Out Date and Time: ______________________".toUpperCase(), pFontHeader);

              table.addCell(phrase);
              table.getDefaultCell().setColspan(6);
              phrase = new Phrase(" ", pFontHeader);
              table.addCell(phrase);
              table.getDefaultCell().setColspan(2);
              phrase =
                  new Phrase("Security Clearance: ___________________".toUpperCase(), pFontHeader);
              table.addCell(phrase);

              phrase = new Phrase("Sign/Stamp: ___________________".toUpperCase(), pFontHeader);
              table.addCell(phrase);
              phrase =
                  new Phrase(
                      "Check-Out Date and Time: ____________________".toUpperCase(), pFontHeader);

              table.addCell(phrase);
              table.getDefaultCell().setColspan(6);

              //  table.addCell(phrase);
              table.getDefaultCell().setColspan(6);
              phrase = new Phrase(" ", pFontHeader);
              table.addCell(phrase);
              phrase =
                  new Phrase(
                      "NB This form should be filled in duplicate, one copy to be retained in the ward and the other one be left at the Main Gate. PLEASE NOTE THAT CHECK-OUT DATE MUST BE THE DATE THE PATIENT LEAVES THE HOSPITAL",
                      pFontHeader11);

              table.addCell(phrase);
              phrase = new Phrase(" ");
              table.addCell(phrase);
              Barcode128 code128 = new Barcode128();
              code128.setCode(patNo + " " + patientName + " " + invoiceNo);
              code128.setBarHeight(20);

              code128.setTextAlignment(Element.ALIGN_CENTER);

              docPdf.add(table);

              System.out.println(cb);

              docPdf.add(code128.createImageWithBarcode(cb, null, null));

            } catch (java.sql.SQLException SqlExec) {

              SqlExec.printStackTrace();

              javax.swing.JOptionPane.showMessageDialog(
                  new javax.swing.JFrame(), SqlExec.getMessage());
            }

            // }

          } catch (com.lowagie.text.BadElementException BadElExec) {

            javax.swing.JOptionPane.showMessageDialog(
                new javax.swing.JFrame(), BadElExec.getMessage());
          }

        } catch (java.io.FileNotFoundException fnfExec) {

          javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), fnfExec.getMessage());
        }
      } catch (com.lowagie.text.DocumentException lwDocexec) {

        javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), lwDocexec.getMessage());
      }

      docPdf.close();
      com.afrisoftech.lib.PDFRenderer.renderPDF(tempFile);

    } catch (java.io.IOException IOexec) {

      javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), IOexec.getMessage());
    }
  }
예제 #4
0
  public void generatePdf(java.lang.String memNo) {

    java.lang.Process wait_for_Pdf2Show;

    java.util.Calendar cal = java.util.Calendar.getInstance();

    java.util.Date dateStampPdf = cal.getTime();

    java.lang.String pdfDateStamp = dateStampPdf.toString();

    try {

      java.io.File tempFile =
          java.io.File.createTempFile("REP" + this.getDateLable() + "_", ".pdf");

      tempFile.deleteOnExit();

      java.lang.Runtime rt = java.lang.Runtime.getRuntime();

      java.lang.String debitTotal = null;

      java.lang.String creditTotal = null;

      //   com.lowagie.text.Document docPdf = new com.lowagie.text.Document(new
      // Rectangle(java.lang.Float.parseFloat(System.getProperty("papersize_width")),
      // java.lang.Float.parseFloat(System.getProperty("papersize_legnth"))));
      com.lowagie.text.Document docPdf = new com.lowagie.text.Document();

      try {

        try {

          com.lowagie.text.pdf.PdfWriter.getInstance(
              docPdf, new java.io.FileOutputStream(tempFile));

          try {

            java.sql.Statement st3 = connectDB.createStatement();
            java.sql.Statement st4 = connectDB.createStatement();
            java.sql.Statement st2x = connectDB.createStatement();

            java.sql.ResultSet rset2x =
                st2x.executeQuery("SELECT rep_currency from pb_hospitalprofile");
            while (rset2x.next()) {
              ks = rset2x.getObject(1).toString();
            }

            com.lowagie.text.HeaderFooter footer =
                new com.lowagie.text.HeaderFooter(
                    new Phrase(
                        "Withholding Tax, where applicable,has been deducted and will be remitted to the Tax Authorities"),
                    false);
            // : "), true);// FontFactory.getFont(com.lowagie.text.FontFactory.HELVETICA, 12,
            // Font.BOLDITALIC,java.awt.Color.blue));

            // docPdf.setFooter(footer);

          } catch (java.sql.SQLException SqlExec) {

            javax.swing.JOptionPane.showMessageDialog(
                new javax.swing.JFrame(), SqlExec.getMessage());
          }

          docPdf.open();

          try {

            com.lowagie.text.pdf.PdfPTable table = new com.lowagie.text.pdf.PdfPTable(6);

            int headerwidths[] = {20, 25, 25, 20, 20, 30};

            table.setWidths(headerwidths);

            table.setWidthPercentage((100));

            com.lowagie.text.pdf.PdfPTable table1 = new com.lowagie.text.pdf.PdfPTable(1);

            int headerwidths1[] = {100};

            table1.setWidths(headerwidths1);

            com.lowagie.text.pdf.PdfPTable table2 = new com.lowagie.text.pdf.PdfPTable(2);

            int headerwidths2[] = {40, 60};

            table2.setWidths(headerwidths2);

            // table.getDefaultCell().setBorder(Rectangle.BOTTOM);

            table.getDefaultCell().setBorderColor(java.awt.Color.WHITE);
            table.getDefaultCell().setColspan(1);
            table.getDefaultCell().setBackgroundColor(java.awt.Color.WHITE);
            table.getDefaultCell().setBorderColor(java.awt.Color.WHITE);

            try {

              java.sql.Statement st = connectDB.createStatement();

              java.sql.Statement st7 = connectDB.createStatement();

              java.sql.Statement st3 = connectDB.createStatement();
              java.sql.Statement st33 = connectDB.createStatement();

              java.sql.ResultSet rset3 =
                  st3.executeQuery(
                      "select hospital_name,postal_code||' '||box_no||' '||town,main_telno||' '||other_telno,initcap(street),main_faxno,email,website,room_no,pin_no,vat_no  from pb_hospitalprofile");

              Phrase phrase = new Phrase("");

              table.getDefaultCell().setColspan(2);

              Image img = Image.getInstance(com.afrisoftech.lib.CompanyLogo.getPath2Logo());
              // Image imgWaterMark = Image.getInstance(System.getProperty("company.watermark"));
              table.getDefaultCell().setColspan(1);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
              table.getDefaultCell().setFixedHeight(45);
              table.addCell(Image.getInstance(com.afrisoftech.lib.CompanyLogo.getPath2Logo()));
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              table.getDefaultCell().setFixedHeight(20);
              // java.sql.Statement st3 = connectDB.createStatement();
              java.sql.ResultSet rs =
                  st.executeQuery(
                      "SELECT DISTINCT hospital_name,box_no,main_telno,main_faxno FROM pb_hospitalprofile");
              while (rs.next()) {

                table.getDefaultCell().setColspan(5);

                table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
                phrase =
                    new Phrase(
                        rs.getObject(1).toString()
                            + " \nP.O. Box "
                            + rs.getObject(2).toString()
                            + " - Tel: "
                            + rs.getObject(3).toString()
                            + " - Fax "
                            + rs.getObject(3).toString(),
                        pFontHeader31);
                table.addCell(phrase);
                table.getDefaultCell().setColspan(6);
                // phrase = new Phrase("P.O. Box " + rs.getObject(2).toString() + " - Tel: " +
                // rs.getObject(3).toString() + " - Fax " + rs.getObject(3).toString(),
                // pFontHeader1);
                // table.addCell(phrase);

              }

              java.sql.ResultSet rset1 =
                  st33.executeQuery(
                      "SELECT postal_address,pin_no,vat_no FROM st_suppliers WHERE supplier_name ILIKE '"
                          + suppName
                          + "'");

              System.out.println(MNo);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              table.getDefaultCell().setColspan(6);
              phrase = new Phrase("PATIENT REFUND VOUCHER", pFontHeader31p);
              table.addCell(phrase);

              table.getDefaultCell().setBorderColor(java.awt.Color.WHITE);

              java.sql.Statement st5 = connectDB.createStatement();
              java.sql.ResultSet rset81 =
                  st5.executeQuery("select * from ac_bills where voucher_no = '" + vouchNo + "'");

              while (rset81.next()) {
                name = rset81.getString("dealer");
                reason = rset81.getString("reason");
                amount = rset81.getString("credit");
              }

              table.getDefaultCell().setColspan(5);
              table.getDefaultCell().setBorderColor(java.awt.Color.WHITE);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              phrase = new Phrase("(DEPOSITS AND SUSPENSE)", pFontHeader31p);
              table.addCell(phrase);

              table.getDefaultCell().setColspan(1);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT);
              phrase = new Phrase("No : " + vouchNo, pFontHeader);
              table.addCell(phrase);

              table.getDefaultCell().setColspan(3);
              table.getDefaultCell().setBorderColor(java.awt.Color.WHITE);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
              phrase = new Phrase("Payee's Name :" + name, pFontHeader);
              table.addCell(phrase);

              table.getDefaultCell().setColspan(3);
              table.getDefaultCell().setBorderColor(java.awt.Color.WHITE);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
              phrase =
                  new Phrase("Payee's Address :...................................", pFontHeader);
              table.addCell(phrase);

              table
                  .getDefaultCell()
                  .setBorder(Rectangle.TOP | Rectangle.BOTTOM | Rectangle.RIGHT | Rectangle.LEFT);
              table.getDefaultCell().setBorderColor(java.awt.Color.BLACK);
              table.getDefaultCell().setColspan(4);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);

              phrase = new Phrase("Particulars", pFontHeader11);
              table.addCell(phrase);
              table.getDefaultCell().setColspan(2);
              phrase = new Phrase("Amount", pFontHeader11);
              table.addCell(phrase);

              table.getDefaultCell().setBorder(Rectangle.TOP | Rectangle.RIGHT | Rectangle.LEFT);
              table.getDefaultCell().setColspan(4);
              phrase = new Phrase("", pFontHeader11);
              table.addCell(phrase);

              table
                  .getDefaultCell()
                  .setBorder(Rectangle.TOP | Rectangle.BOTTOM | Rectangle.RIGHT | Rectangle.LEFT);
              table.getDefaultCell().setBorderColor(java.awt.Color.BLACK);
              table.getDefaultCell().setColspan(1);
              phrase = new Phrase("Ksh. ", pFontHeader11);
              table.addCell(phrase);

              table.getDefaultCell().setBorderColor(java.awt.Color.BLACK);
              table.getDefaultCell().setColspan(1);
              phrase = new Phrase("Cts. ", pFontHeader11);
              table.addCell(phrase);

              table.getDefaultCell().setBorder(Rectangle.BOTTOM | Rectangle.RIGHT | Rectangle.LEFT);
              table.getDefaultCell().setBorderColor(java.awt.Color.BLACK);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
              table.getDefaultCell().setColspan(4);
              table.getDefaultCell().setFixedHeight(60);
              phrase = new Phrase(reason, pFontHeader1);
              table.addCell(phrase);

              table
                  .getDefaultCell()
                  .setBorder(Rectangle.TOP | Rectangle.BOTTOM | Rectangle.RIGHT | Rectangle.LEFT);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              table.getDefaultCell().setBorderColor(java.awt.Color.BLACK);
              table.getDefaultCell().setColspan(2);
              table.getDefaultCell().setFixedHeight(60);
              phrase = new Phrase(amount, pFontHeader1);
              table.addCell(phrase);

              table.getDefaultCell().setBorderColor(java.awt.Color.BLACK);
              //                            table.getDefaultCell().setColspan(1);
              //                            table.getDefaultCell().setFixedHeight(60);
              //                            phrase = new Phrase("", pFontHeader11);
              //                            table.addCell(phrase);

              table.getDefaultCell().setColspan(4);
              table.getDefaultCell().setFixedHeight(20);
              phrase = new Phrase(" Total", pFontHeader11);
              table.addCell(phrase);

              table.getDefaultCell().setBorderColor(java.awt.Color.BLACK);
              table.getDefaultCell().setColspan(2);
              phrase = new Phrase(amount, pFontHeader11);
              table.addCell(phrase);

              String cashWord = "";
              java.sql.ResultSet rset_cash =
                  st7.executeQuery(
                      "select replace(cash_words('"
                          + Double.parseDouble(amount)
                          + "'::money),'dollars',' Kenya Shillings only')");
              if (rset_cash.next()) {
                cashWord = rset_cash.getString(1);
              }

              table.getDefaultCell().setColspan(6);
              table.getDefaultCell().setBorderColor(java.awt.Color.WHITE);

              phrase =
                  new Phrase(
                      "Amount payable is Kshs "
                          + amount
                          + " (amount in words) "
                          + cashWord
                          + " only.",
                      pFontHeader1);
              table.addCell(phrase);

              table
                  .getDefaultCell()
                  .setBorder(Rectangle.TOP | Rectangle.BOTTOM | Rectangle.RIGHT | Rectangle.LEFT);
              table.getDefaultCell().setBorderColor(java.awt.Color.BLACK);
              table.getDefaultCell().setColspan(6);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              phrase = new Phrase("Authority References No.", pFontHeader11);
              table.addCell(phrase);

              table.getDefaultCell().setBorder(Rectangle.TOP | Rectangle.RIGHT);
              table.getDefaultCell().setBorderColor(java.awt.Color.BLACK);
              table.getDefaultCell().setColspan(3);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              phrase = new Phrase("EXAMINATION", pFontHeader11);
              table.addCell(phrase);

              table.getDefaultCell().setBorder(Rectangle.TOP | Rectangle.LEFT);
              table.getDefaultCell().setBorderColor(java.awt.Color.BLACK);
              table.getDefaultCell().setColspan(3);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              phrase = new Phrase("Internal Audit", pFontHeader11);
              table.addCell(phrase);

              table.getDefaultCell().setBorder(Rectangle.RIGHT);
              table.getDefaultCell().setColspan(3);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              phrase =
                  new Phrase(
                      "Voucher Examined by...........................................",
                      pFontHeader1);
              table.addCell(phrase);

              table.getDefaultCell().setBorder(Rectangle.LEFT);
              table.getDefaultCell().setColspan(3);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              phrase =
                  new Phrase(
                      "...............................................................",
                      pFontHeader1);
              table.addCell(phrase);

              table.getDefaultCell().setBorder(Rectangle.RIGHT);
              table.getDefaultCell().setColspan(3);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              phrase = new Phrase("Date :..............................", pFontHeader1);
              table.addCell(phrase);

              table.getDefaultCell().setBorder(Rectangle.LEFT);
              table.getDefaultCell().setColspan(3);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              phrase = new Phrase("Date :..................................", pFontHeader1);
              table.addCell(phrase);

              table.getDefaultCell().setBorder(Rectangle.TOP | Rectangle.RIGHT);
              table.getDefaultCell().setBorderColor(java.awt.Color.BLACK);
              table.getDefaultCell().setColspan(3);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              phrase = new Phrase("DEPOSITS AND SUSPENSE CERTIFICATE", pFontHeader11);
              table.addCell(phrase);

              table.getDefaultCell().setBorder(Rectangle.TOP | Rectangle.LEFT);
              table.getDefaultCell().setBorderColor(java.awt.Color.BLACK);
              table.getDefaultCell().setColspan(3);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              phrase = new Phrase("AUTHORIZATION", pFontHeader11);
              table.addCell(phrase);

              table.getDefaultCell().setBorder(Rectangle.RIGHT);
              table.getDefaultCell().setColspan(3);
              table.getDefaultCell().setFixedHeight(40);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              phrase =
                  new Phrase(
                      "I certify that the amount of payment has been recorded in the relevant register and that adequate funds previously deposited and credited to A/c No ............................... has not been repaid.",
                      pFontHeader12);
              table.addCell(phrase);

              table.getDefaultCell().setBorder(Rectangle.LEFT);
              table.getDefaultCell().setColspan(3);
              table.getDefaultCell().setFixedHeight(40);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              phrase =
                  new Phrase(
                      "I certify that the payment has been made on proper authority. Where appropriate a relevant certificate has been completed in the space provided overleaf",
                      pFontHeader12);
              table.addCell(phrase);

              table.getDefaultCell().setBorder(Rectangle.RIGHT);
              table.getDefaultCell().setColspan(3);
              table.getDefaultCell().setFixedHeight(50);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              phrase =
                  new Phrase(
                      "Net Deposit brought forward from previous month.\n\n  A/c No ...........................     Ksh....................... \n Less/Add:",
                      pFontHeader12);
              table.addCell(phrase);

              table.getDefaultCell().setBorder(Rectangle.LEFT);
              table.getDefaultCell().setColspan(3);
              table.getDefaultCell().setFixedHeight(50);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              phrase =
                  new Phrase(
                      "I am satisfied that the amount of payment as shown above is a proper charge to the item shown here below and hereby AUTHORIZE payment thereof without any alteration.",
                      pFontHeader12);
              table.addCell(phrase);

              table.getDefaultCell().setBorder(Rectangle.RIGHT);
              table.getDefaultCell().setColspan(3);
              table.getDefaultCell().setFixedHeight(30);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              phrase =
                  new Phrase(
                      "Total payment/receipt current month Ksh.........................\n\n"
                          + "Balance       (+) Kshs.....................",
                      pFontHeader12);
              table.addCell(phrase);

              table.getDefaultCell().setBorder(Rectangle.LEFT);
              table.getDefaultCell().setColspan(3);
              table.getDefaultCell().setFixedHeight(30);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              phrase = new Phrase("", pFontHeader1);
              table.addCell(phrase);

              table.getDefaultCell().setBorder(Rectangle.RIGHT);
              table.getDefaultCell().setColspan(3);
              table.getDefaultCell().setFixedHeight(30);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              phrase =
                  new Phrase(
                      "I certify that proper reconciliation of above balance has been carried out and that this payment is based on the reconciled balance.",
                      pFontHeader12);
              table.addCell(phrase);

              table.getDefaultCell().setBorder(Rectangle.LEFT);
              table.getDefaultCell().setColspan(3);
              table.getDefaultCell().setFixedHeight(20);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              phrase =
                  new Phrase(
                      "Signature...............................................\n Accounting Officer",
                      pFontHeader12);
              table.addCell(phrase);

              table.getDefaultCell().setBorder(Rectangle.RIGHT | Rectangle.BOTTOM);
              table.getDefaultCell().setColspan(3);
              table.getDefaultCell().setFixedHeight(30);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              phrase =
                  new Phrase(
                      "Date...............................  Signature...............................\n Accountant I/c Deposits and Suspense",
                      pFontHeader12);
              table.addCell(phrase);

              table.getDefaultCell().setBorder(Rectangle.LEFT | Rectangle.BOTTOM);
              table.getDefaultCell().setColspan(3);
              table.getDefaultCell().setFixedHeight(20);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              phrase = new Phrase("Date.........................................", pFontHeader12);
              table.addCell(phrase);

              table.getDefaultCell().setBorder(Rectangle.RIGHT | Rectangle.BOTTOM | Rectangle.TOP);
              table.getDefaultCell().setColspan(1);
              table.getDefaultCell().setFixedHeight(45);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              phrase = new Phrase("Vote", pFontHeader11);
              table.addCell(phrase);

              table
                  .getDefaultCell()
                  .setBorder(Rectangle.RIGHT | Rectangle.BOTTOM | Rectangle.LEFT | Rectangle.TOP);
              table.getDefaultCell().setColspan(2);
              table.getDefaultCell().setFixedHeight(45);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              phrase = new Phrase("Head", pFontHeader11);
              table.addCell(phrase);

              table
                  .getDefaultCell()
                  .setBorder(Rectangle.RIGHT | Rectangle.BOTTOM | Rectangle.LEFT | Rectangle.TOP);
              table.getDefaultCell().setColspan(2);
              table.getDefaultCell().setFixedHeight(45);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              phrase = new Phrase("Sub-Head", pFontHeader11);
              table.addCell(phrase);

              table.getDefaultCell().setBorder(Rectangle.LEFT | Rectangle.BOTTOM | Rectangle.TOP);
              table.getDefaultCell().setColspan(1);
              table.getDefaultCell().setFixedHeight(45);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              phrase = new Phrase("Item", pFontHeader11);
              table.addCell(phrase);

              table.getDefaultCell().setBorderColor(java.awt.Color.WHITE);
              table.getDefaultCell().setColspan(6);
              table.getDefaultCell().setFixedHeight(15);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              phrase = new Phrase("", pFontHeader11);
              table.addCell(phrase);

              table
                  .getDefaultCell()
                  .setBorder(Rectangle.RIGHT | Rectangle.BOTTOM | Rectangle.LEFT | Rectangle.TOP);
              table.getDefaultCell().setBorderColor(java.awt.Color.BLACK);
              table.getDefaultCell().setColspan(1);
              table.getDefaultCell().setFixedHeight(20);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              phrase = new Phrase("Account No.", pFontHeader11);
              table.addCell(phrase);

              table.getDefaultCell().setColspan(1);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              phrase = new Phrase("Dept. Vch. No.", pFontHeader11);
              table.addCell(phrase);

              table.getDefaultCell().setColspan(1);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              phrase = new Phrase("Station", pFontHeader11);
              table.addCell(phrase);

              table.getDefaultCell().setColspan(2);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              phrase = new Phrase("Cash Book", pFontHeader11);
              table.addCell(phrase);

              table.getDefaultCell().setColspan(1);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              phrase = new Phrase("Amount.", pFontHeader11);
              table.addCell(phrase);

              table.getDefaultCell().setColspan(1);
              table.getDefaultCell().setFixedHeight(50);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              phrase = new Phrase("", pFontHeader11);
              table.addCell(phrase);

              table.getDefaultCell().setColspan(1);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              phrase = new Phrase("", pFontHeader11);
              table.addCell(phrase);

              table.getDefaultCell().setColspan(1);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              phrase = new Phrase("", pFontHeader11);
              table.addCell(phrase);

              table.getDefaultCell().setColspan(1);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              phrase = new Phrase("Vch. No", pFontHeader11);
              table.addCell(phrase);

              table.getDefaultCell().setColspan(1);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              phrase = new Phrase("Date", pFontHeader11);
              table.addCell(phrase);

              table.getDefaultCell().setColspan(1);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              phrase = new Phrase("", pFontHeader11);
              table.addCell(phrase);

              table.getDefaultCell().setBorderColor(java.awt.Color.WHITE);
              table.getDefaultCell().setFixedHeight(0);
              table.getDefaultCell().setColspan(6);
              phrase = new Phrase("", pFontHeader1);
              table.addCell(phrase);
              //
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
              table.getDefaultCell().setColspan(3);
              phrase =
                  new Phrase("Name: .......................................... ", pFontHeader1);
              table.addCell(phrase);
              table.getDefaultCell().setColspan(3);
              phrase =
                  new Phrase(
                      "ID No : ............................................... ", pFontHeader1);
              table.addCell(phrase);

              table.getDefaultCell().setBorderColor(java.awt.Color.WHITE);
              table.getDefaultCell().setFixedHeight(0);
              table.getDefaultCell().setColspan(6);
              phrase = new Phrase("", pFontHeader1);
              table.addCell(phrase);

              table.getDefaultCell().setColspan(3);
              phrase =
                  new Phrase(
                      "Signature : .......................................... ", pFontHeader1);
              table.addCell(phrase);
              table.getDefaultCell().setColspan(3);
              phrase =
                  new Phrase(
                      "Date: ............................................... ", pFontHeader1);
              table.addCell(phrase);

              table.getDefaultCell().setColspan(6);
              //
              // table.getDefaultCell().setBorderColor(java.awt.Color.BLACK);
              //                             table.getDefaultCell().setBorder(Rectangle.BOTTOM);
              phrase = new Phrase("", pFontHeader1);
              table.addCell(phrase);

              docPdf.add(table);

            } catch (java.sql.SQLException SqlExec) {

              SqlExec.printStackTrace();

              javax.swing.JOptionPane.showMessageDialog(
                  new javax.swing.JFrame(), SqlExec.getMessage());
            }

            // }

          } catch (com.lowagie.text.BadElementException BadElExec) {

            BadElExec.printStackTrace();

            javax.swing.JOptionPane.showMessageDialog(
                new javax.swing.JFrame(), BadElExec.getMessage());
          }

        } catch (java.io.FileNotFoundException fnfExec) {

          fnfExec.printStackTrace();

          javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), fnfExec.getMessage());
        }
      } catch (com.lowagie.text.DocumentException lwDocexec) {

        lwDocexec.printStackTrace();

        javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), lwDocexec.getMessage());
      }

      docPdf.close();

      docPdf.close();
      com.afrisoftech.lib.PDFRenderer.renderPDF(tempFile);

    } catch (java.io.IOException IOexec) {

      IOexec.printStackTrace();

      javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), IOexec.getMessage());
    }
  }