Esempio n. 1
0
  public void pintaCodigoBarras() {

    Image imageLogo;
    Image imageBarc = null;
    String imageUrl;

    Font fuente = new Font(FontFamily.HELVETICA, 8, Font.NORMAL, new BaseColor(64, 64, 64));
    BaseColor bkcolor = new BaseColor(255, 255, 255);

    try {

      PdfPTable table = new PdfPTable(new float[] {1, 1, 1, 1, 1});
      // table.setTotalWidth(900);
      table.getDefaultCell().setBorder(0);
      //	imageUrl = PropiedadesJLet.getInstance().getProperty("path.img.logos") +
      // "logo_recibos.png";

      // imageLogo = Image.getInstance(imageUrl);

      int yinic = 805;
      int xinic = 0;

      int posicion = 0; // posicion donde comenzara a imprimir

      // for (int i = 0; i < listcode.size(); i++){

      String codeunic = codvalue;

      // System.out.println(codeunic.substring(0,5) +"-"+ codeunic.substring(6,7));

      imageBarc = getBarcode(documento, writer, codeunic);

      PdfPTable tablein = new PdfPTable(new float[] {1f, 3f, 1f});

      tablein.getDefaultCell().setBorder(0);
      tablein.setTotalWidth(documento.getPageSize().getWidth());

      tablein.addCell(FRAparen.getCelda(" ", fuente, bkcolor, "center")).setBorder(0);
      // tablein.addCell(imageLogo);
      tablein.addCell(FRAparen.getCelda(" ", fuente, bkcolor, "center")).setBorder(0);

      tablein.addCell(FRAparen.getCelda(" ", fuente, bkcolor, "center")).setBorder(0);
      tablein.addCell(imageBarc);
      tablein.addCell(FRAparen.getCelda(" ", fuente, bkcolor, "center")).setBorder(0);

      table.addCell(tablein);

      imageBarc.scaleAbsolute(anchcdba, altocdba);
      imageBarc.setAbsolutePosition(xposicio, yposicio);

      documento.add(imageBarc);

    } catch (Exception e) {

    }
  }
 private static void createCheckbox(
     PdfWriter writer,
     Document accountingDocument,
     Font font,
     String[] label,
     int xPosition,
     int yPosition,
     boolean[] checked,
     int pageNr) {
   PdfContentByte canvas = writer.getDirectContent();
   //    Rectangle rect;
   //    PdfFormField field;
   //    RadioCheckField checkbox;
   try {
     Image checkbox_checked =
         Image.getInstance(MainWindow.class.getResource("checkbox_checked.jpg"));
     checkbox_checked.scaleAbsolute(10f, 10f);
     Image checkbox = Image.getInstance(MainWindow.class.getResource("checkbox.jpg"));
     checkbox.scaleAbsolute(10f, 10f);
     for (int i = 0; i < label.length; i++) {
       Image checkboxImage;
       if (checked[i]) {
         checkboxImage = Image.getInstance(checkbox_checked);
       } else {
         checkboxImage = Image.getInstance(checkbox);
       }
       checkboxImage.setAbsolutePosition(xPosition, (yPosition - 10 - i * 15));
       accountingDocument.add(checkboxImage);
       ColumnText.showTextAligned(
           canvas,
           Element.ALIGN_LEFT,
           new Phrase(label[i], font),
           (xPosition + 16),
           (yPosition - 8 - i * 15),
           0);
     }
     // TODO: for JDK7 use Multicatch
   } catch (Exception e) { // com.itextpdf.text.DocumentException | java.io.IOException e) {
     UtilityBox.getInstance()
         .displayErrorPopup(
             "Abrechnung", "Fehler beim Erstellen der Abrechnung: " + e.getMessage());
   }
 }
Esempio n. 3
0
  public void addTitlePage(Document document, CustomerOrder customerOrder)
      throws DocumentException {
    Paragraph preface = new Paragraph();
    // We add one empty line
    addEmptyLine(preface, 1);
    Image image = null;
    try {
      image = Image.getInstance("img/gfcLogo.jpg");
      image.scaleAbsolute(100f, 100f);
      image.setAlignment(Image.ALIGN_LEFT);
    } catch (IOException e) {
      e.printStackTrace();
    }
    document.add(image);
    // Lets write a big header
    Phrase invoice = new Phrase();
    invoice.add(new Chunk("Generation For Christ", companyName));
    invoice.add(new Chunk("                                   Invoice", companyName));
    preface.add(new Paragraph(invoice));
    // preface.add(new Paragraph( "));

    preface.add(new Paragraph("                      We Make Disciples", companySlogan));
    // preface.add(new Paragraph( "                Invoice", companyName));
    // addEmptyLine(preface, 1);
    Date date = new Date();
    String dateFormat = new SimpleDateFormat("dd/MM/yyyy").format(date);
    preface.add(
        new Paragraph(
            "                                                                                                                                         DATE:   "
                + dateFormat,
            details));
    preface.add(
        new Paragraph(
            "25 James Street, Dandenong                                                                                   ORDER ID:    "
                + customerOrder.getOrderId(),
            details));
    preface.add(new Paragraph("Melbourne, Victoria, 3175", details));
    preface.add(new Paragraph("Phone # ", details));

    // Will create: Report generated by: _name, _date
    // preface.add(new Paragraph("Report generated by: " + System.getProperty("user.name") + ", " +
    // new Date(), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    //         smallBold));
    // addEmptyLine(preface, 3);
    // preface.add(new Paragraph("This document contains confidential information of GFC's member",
    //         smallBold));

    document.add(preface);
    // Start a new page
    // document.newPage();
  }
Esempio n. 4
0
  public void scale(int width, int height) {
    int targetWidth = width;
    int targetHeight = height;

    if (targetWidth == -1) {
      targetWidth = (int) (getWidth() * ((double) targetHeight / getHeight()));
    }

    if (targetHeight == -1) {
      targetHeight = (int) (getHeight() * ((double) targetWidth / getWidth()));
    }

    _image.scaleAbsolute(targetWidth, targetHeight);
  }
Esempio n. 5
0
 private Image loadDrawable(int resId, float scale) {
   Drawable d = mContext.getResources().getDrawable(resId);
   BitmapDrawable bitDw = ((BitmapDrawable) d);
   Bitmap bmp = bitDw.getBitmap();
   ByteArrayOutputStream stream = new ByteArrayOutputStream();
   bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
   Image image = null;
   try {
     image = Image.getInstance(stream.toByteArray());
     image.scaleAbsolute(scale, scale);
   } catch (Exception e) {
     e.printStackTrace();
   }
   return image;
 }
  /**
   * speichert / schreibt die PDF
   *
   * @return
   * @throws IOException
   */
  @Override
  public void speichern(Object o, String pfad) throws IOException {

    Document doc = new Document(PageSize.LETTER.rotate());
    try {
      PdfWriter.getInstance(doc, new FileOutputStream(pfad));
      doc.open();

      Paragraph p = new Paragraph("Dame - Spielstand \n"); // Ueberschrift in
      // der PDF
      doc.add(p);
      Image screenshot = Image.getInstance("screenshotSpiel.png"); // liest den
      // Screenshot
      // ein
      screenshot.scaleAbsolute(750f, 420f); // setzt Bild auf bestimmte Groesse

      doc.add(screenshot);

      // logger.log("PDF wurde erstellt. Projekt bitte refreshen.");
      doc.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  public static void main(String[] args) {
    try {
      // Read file using PdfReader
      PdfReader pdfReader = new PdfReader("HelloWorld.pdf");

      // Modify file using PdfReader
      PdfStamper pdfStamper =
          new PdfStamper(pdfReader, new FileOutputStream("HelloWorld-modified.pdf"));

      Image image = Image.getInstance("temp.png");
      image.scaleAbsolute(100, 50);
      image.setAbsolutePosition(100f, 700f);

      for (int i = 1; i <= pdfReader.getNumberOfPages(); i++) {
        PdfContentByte content = pdfStamper.getUnderContent(i);
        content.addImage(image);
      }

      pdfStamper.close();

    } catch (IOException | DocumentException e) {
      logger.warn("failed to ...." + e);
    }
  }
  public PDFCreator(
      String name,
      String amount,
      String procedure,
      String dateIssued,
      String chargeDate,
      int patient_ID,
      int billing_ID) {

    this.name = name;
    this.amount = amount;
    this.procedure = procedure;
    this.dateIssued = dateIssued;
    this.chargeDate = chargeDate;
    this.patient_ID = patient_ID;
    this.billing_ID = billing_ID;

    Document document = new Document();
    try {
      PdfWriter writer =
          PdfWriter.getInstance(document, new FileOutputStream("Bill" + billing_ID + ".pdf"));
      document.open();

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

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

           PdfPCell cell1 = new PdfPCell(new Paragraph("Cell 1"));
           cell1.setBorderColor(BaseColor.BLUE);
           cell1.setPaddingLeft(10);
           cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
           cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);

           PdfPCell cell2 = new PdfPCell(new Paragraph("Cell 2"));
           cell2.setBorderColor(BaseColor.GREEN);
           cell2.setPaddingLeft(10);
           cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
           cell2.setVerticalAlignment(Element.ALIGN_MIDDLE);

           PdfPCell cell3 = new PdfPCell(new Paragraph("Cell 3"));
           cell3.setBorderColor(BaseColor.RED);
           cell3.setPaddingLeft(10);
           cell3.setHorizontalAlignment(Element.ALIGN_CENTER);
           cell3.setVerticalAlignment(Element.ALIGN_MIDDLE);



           //To avoid having the cell border and the content overlap, if you are having thick cell borders
           //cell1.setUserBorderPadding(true);
           //cell2.setUserBorderPadding(true);
           //cell3.setUserBorderPadding(true);

           table.addCell(cell1);
           table.addCell(cell2);
           table.addCell(cell3);
           table.addCell("cell 4");
           table.addCell("Cell 5");
      */

      // Add Image
      Image image1 = Image.getInstance("Pictures\\Logo.PNG");
      // Fixed Positioning
      image1.setAbsolutePosition(150f, 750f);
      image1.scaleAbsolute(image1.getScaledWidth() / 2, image1.getScaledHeight() / 2);

      // Scale to new height and new width of image
      // image1.scaleAbsolute(500, 200);

      // Add to document
      document.add(image1);

      Paragraph companyInfo =
          new Paragraph(
              "Nimbus Clinical Management \n8421 West Forest Drive,\nFayetteville, Arkansas, 72701\n555-382-9876\n12/31/2016");
      companyInfo.setSpacingBefore(55f);
      companyInfo.setSpacingAfter(10f);

      Paragraph billingInvoice = new Paragraph("Billing Invoice");
      billingInvoice.setAlignment(Element.ALIGN_CENTER);

      document.add(companyInfo);
      document.add(billingInvoice);
      // document.add(paragraphTable1);
      document.add(createFirstTable());

      document.close();
      writer.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Esempio n. 9
0
  public static void main(String[] args) throws MalformedURLException, IOException {

    // special font sizes
    Font bfBold12 = new Font(FontFamily.TIMES_ROMAN, 12, Font.BOLD, new BaseColor(0, 0, 0));
    Font bf12 = new Font(FontFamily.TIMES_ROMAN, 12);
    Document document = new Document();
    Font GRAY_NORMAL = new Font(FontFamily.HELVETICA, 18, Font.BOLD, BaseColor.GRAY);
    float fntSize = 6.7f;
    try {
      PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("invoice.pdf"));
      document.open();

      // Add Image
      Image image1 =
          Image.getInstance(
              "E:/TECHVISIO/workspace/eServe/localRepo/src/main/webapp/static/images/Honda.jpg");
      // Fixed Positioning
      image1.setAbsolutePosition(35f, 780f);
      // Scale to new height and new width of image
      image1.scaleAbsolute(50, 50);
      // Add to document
      document.add(image1);

      PdfPTable table = new PdfPTable(1);

      PdfPCell cell1 = new PdfPCell(new Paragraph("INVOICE", GRAY_NORMAL));
      cell1.setBorder(Rectangle.NO_BORDER);
      cell1.setHorizontalAlignment(Element.ALIGN_RIGHT);
      cell1.setVerticalAlignment(Element.ALIGN_RIGHT);

      table.addCell(cell1);
      document.add(table);

      Paragraph clientName =
          new Paragraph(
              "Techvisio Solutions Pvt. Ltd.", FontFactory.getFont(FontFactory.COURIER, fntSize));
      clientName.setAlignment(Element.ALIGN_LEFT);
      document.add(clientName);

      Paragraph address =
          new Paragraph("5/1608 Vasundhra", FontFactory.getFont(FontFactory.COURIER, fntSize));
      address.setAlignment(Element.ALIGN_LEFT);
      document.add(address);

      Paragraph city =
          new Paragraph("Ghaziabad, 201012", FontFactory.getFont(FontFactory.COURIER, fntSize));
      city.setAlignment(Element.ALIGN_LEFT);
      document.add(city);

      Paragraph state =
          new Paragraph("Uttar Pradesh", FontFactory.getFont(FontFactory.COURIER, fntSize));
      state.setAlignment(Element.ALIGN_LEFT);
      document.add(state);

      // specify column widths
      float[] columnWidths = {2f, 8f, 3f};
      // create PDF table with the given widths
      PdfPTable unitTable = new PdfPTable(columnWidths);
      // set table width a percentage of the page width

      unitTable.setWidthPercentage(100f);

      // insert column headings

      insertCell(unitTable, " ", Element.ALIGN_LEFT, 4, bfBold12, Rectangle.NO_BORDER);
      insertCell(unitTable, "S. No.", Element.ALIGN_LEFT, 1, bf12, Rectangle.BOX);
      insertCell(unitTable, "Product Description", Element.ALIGN_LEFT, 1, bf12, Rectangle.BOX);
      insertCell(unitTable, "Price", Element.ALIGN_LEFT, 1, bf12, Rectangle.BOX);
      insertCell(unitTable, " ", Element.ALIGN_LEFT, 4, bfBold12, Rectangle.BOX);
      insertCell(unitTable, "", Element.ALIGN_LEFT, 1, bf12, Rectangle.BOX);
      insertCell(
          unitTable,
          "unitId 2 Machine Serial No : HKID812K",
          Element.ALIGN_LEFT,
          1,
          bf12,
          Rectangle.BOX);
      insertCell(unitTable, "80000", Element.ALIGN_LEFT, 1, bf12, Rectangle.BOX);
      document.add(unitTable);

      document.close();
      writer.close();
    } catch (DocumentException e) {
      e.printStackTrace();
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    }
  }
Esempio n. 10
0
  public PdfPTable createPdf(
      String filename,
      String n,
      long r,
      String b,
      int s,
      String ca,
      long dd,
      double damt,
      String bn,
      Date1 ddate)
      throws DocumentException, IOException {

    int d = dur();

    PdfPTable table1 = new PdfPTable(6);
    table1.setWidthPercentage(25);
    float[] columnWidths = new float[] {2f, 2f, 2f, 2f, 2f, 2f};
    table1.setWidths(columnWidths);
    Image image2 = Image.getInstance("/home/root1/index.jpg");
    image2.scaleAbsolute(45f, 45f);
    PdfPCell cell = new PdfPCell(image2);
    cell.setBorder(PdfPCell.NO_BORDER);
    table1.addCell(cell);
    Paragraph p0 =
        new Paragraph(
            "ANNA UNIVERSITY, CHENNAI"
                + "\n "
                + " Challan for Payment into Indian Bank"
                + "\n "
                + "(Chromepet Branch)",
            new Font(FontFamily.TIMES_ROMAN, 11, Font.BOLD));
    PdfPCell cell0 = new PdfPCell(p0);
    cell0.setColspan(5);
    cell0.setBorder(PdfPCell.NO_BORDER);
    cell0.setHorizontalAlignment(Element.ALIGN_CENTER);
    table1.addCell(cell0);
    table1.setHorizontalAlignment(Element.ALIGN_LEFT);
    PdfPCell c7 = new PdfPCell(new Phrase(" "));
    c7.setColspan(6);
    c7.setBorder(PdfPCell.NO_BORDER);
    c7.setBorder(Rectangle.BOTTOM);
    table1.addCell(c7);

    PdfPCell c1 =
        new PdfPCell(
            new Phrase(
                "INDIAN BANK A/c. No.8 6 4 4 0 2 6 7 3 ",
                new Font(FontFamily.TIMES_ROMAN, 11, Font.BOLD)));
    c1.setColspan(6);
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setBorder(Rectangle.BOTTOM);
    table1.addCell(c1);

    PdfPCell c2 =
        new PdfPCell(
            new Phrase(
                "REGULAR PROGRAMME - UG and PG", new Font(FontFamily.TIMES_ROMAN, 11, Font.BOLD)));
    c2.setColspan(6);
    c2.setHorizontalAlignment(Element.ALIGN_CENTER);
    c2.setBorder(Rectangle.BOTTOM);
    table1.addCell(c2);
    Paragraph pad = new Paragraph();
    pad.add(new Chunk(String.valueOf(d), new Font(FontFamily.TIMES_ROMAN, 11, Font.BOLD)));

    PdfPCell c3 =
        new PdfPCell(
            new Phrase(
                "Fee payable for ODD Semester - ",
                new Font(FontFamily.TIMES_ROMAN, 11, Font.BOLD)));
    c3.setColspan(4);
    c3.setHorizontalAlignment(Element.ALIGN_CENTER);
    c3.setBorder(Rectangle.BOTTOM);
    table1.addCell(c3);
    PdfPCell c3a = new PdfPCell(pad);
    // c3a.setColspan(2);
    c3a.setVerticalAlignment(Element.ALIGN_BOTTOM);
    c3a.setHorizontalAlignment(Element.ALIGN_RIGHT);
    c3a.setBorder(Rectangle.BOTTOM);
    table1.addCell(c3a);

    Paragraph pad1 = new Paragraph("-");
    pad1.add(new Chunk(String.valueOf(d + 1), new Font(FontFamily.TIMES_ROMAN, 11, Font.BOLD)));
    PdfPCell c3b = new PdfPCell(pad1);
    // c3a.setColspan(2);
    c3b.setHorizontalAlignment(Element.ALIGN_LEFT);
    c3b.setBorder(Rectangle.BOTTOM);
    table1.addCell(c3b);

    PdfPCell c4 =
        new PdfPCell(new Phrase(filename, new Font(FontFamily.TIMES_ROMAN, 11, Font.BOLD)));
    c4.setColspan(6);
    c4.setHorizontalAlignment(Element.ALIGN_CENTER);
    c4.setBorder(Rectangle.BOTTOM);
    table1.addCell(c4);
    String g = n.toUpperCase();
    PdfPCell c5 = new PdfPCell(new Phrase("Name:     " + g, new Font(FontFamily.TIMES_ROMAN, 11)));
    c5.setBorder(Rectangle.BOTTOM);
    c5.setColspan(3);
    table1.addCell(c5);

    Paragraph pa = new Paragraph();
    pa.add(new Chunk(String.valueOf(r)));
    // PdfPCell cell9 = new PdfPCell(pa);

    PdfPCell c6 = new PdfPCell(new Paragraph("Roll No:", new Font(FontFamily.TIMES_ROMAN, 11)));

    c6.setBorder(Rectangle.BOTTOM);
    table1.addCell(c6);

    PdfPCell c6a = new PdfPCell(pa);
    c6a.setColspan(2);
    c6a.setHorizontalAlignment(Element.ALIGN_LEFT);
    c6a.setBorder(Rectangle.BOTTOM);
    table1.addCell(c6a);

    PdfPCell c8 =
        new PdfPCell(new Phrase("Degree:       " + "UG", new Font(FontFamily.TIMES_ROMAN, 11)));
    c8.setColspan(4);
    c8.setBorder(PdfPCell.NO_BORDER);
    c8.setBorder(Rectangle.BOTTOM);
    table1.addCell(c8);

    PdfPCell c9 = new PdfPCell(new Phrase("Campus : MITC ", new Font(FontFamily.TIMES_ROMAN, 11)));
    c9.setColspan(2);
    c9.setBorder(PdfPCell.NO_BORDER);
    c9.setBorder(Rectangle.BOTTOM);
    table1.addCell(c9);
    String g1 = b.toUpperCase();
    PdfPCell c10 =
        new PdfPCell(
            new Phrase("Branch of Study :      " + g1, new Font(FontFamily.TIMES_ROMAN, 11)));
    c10.setColspan(6);
    c10.setBorder(Rectangle.BOTTOM);
    table1.addCell(c10);
    Paragraph pa1 = new Paragraph();
    pa1.add(new Chunk(String.valueOf(s), new Font(FontFamily.TIMES_ROMAN, 11)));
    // PdfPCell cell9 = new PdfPCell(pa1);
    PdfPCell c19 = new PdfPCell(new Paragraph("Semester: ", new Font(FontFamily.TIMES_ROMAN, 10)));
    c19.setHorizontalAlignment(Element.ALIGN_LEFT);
    c19.setBorder(Rectangle.BOTTOM);
    table1.addCell(c19);
    PdfPCell c19a = new PdfPCell(pa1);
    c19a.setColspan(2);
    c19a.setHorizontalAlignment(Element.ALIGN_LEFT);
    c19a.setBorder(Rectangle.BOTTOM);
    table1.addCell(c19a);

    PdfPCell c24 = new PdfPCell(new Phrase("Category:  ", new Font(FontFamily.TIMES_ROMAN, 10)));
    c24.setHorizontalAlignment(Element.ALIGN_LEFT);
    c24.setBorder(Rectangle.BOTTOM);
    String gc = ca.toUpperCase();
    PdfPCell c25 = new PdfPCell(new Paragraph(gc, new Font(FontFamily.TIMES_ROMAN, 10)));
    c25.setColspan(2);
    c25.setHorizontalAlignment(Element.ALIGN_LEFT);
    c25.setBorder(Rectangle.BOTTOM);
    table1.addCell(c24);
    table1.addCell(c25);
    Paragraph pp1 =
        new Paragraph(
            "A.   CONSOLIDATED FEE PER SEMESTER"
                + "\n "
                + "(select and pay the fee relevant to the programme) ",
            new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
    PdfPCell c31 = new PdfPCell(pp1);
    c31.setColspan(6);
    c31.setHorizontalAlignment(Element.ALIGN_CENTER);
    table1.addCell(c31);
    Phrase p1 = new Phrase("SL.No", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
    PdfPCell cell1 = new PdfPCell(p1);
    cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table1.addCell(cell1);
    Phrase p2 =
        new Phrase("Fee for the Programme of  ", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
    PdfPCell cell2 = new PdfPCell(p2);
    cell2.setColspan(3);
    cell2.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
    table1.addCell(cell2);
    Phrase p3 =
        new Phrase("SC/ST/\n" + "DA/FG Rs.", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
    PdfPCell cell3 = new PdfPCell(p3);
    cell3.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell3.setHorizontalAlignment(Element.ALIGN_CENTER);
    table1.addCell(cell3);
    Phrase p4 = new Phrase("Others Rs.", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
    PdfPCell cell4 = new PdfPCell(p4);
    cell4.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell4.setHorizontalAlignment(Element.ALIGN_CENTER);
    table1.addCell(cell4);
    Phrase p5 = new Phrase("1.", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
    PdfPCell cell5 = new PdfPCell(p5);
    cell5.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell5.setHorizontalAlignment(Element.ALIGN_CENTER);
    table1.addCell(cell5);
    Phrase p6 =
        new Phrase("B.E / B.TECH. Programme ", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
    PdfPCell cell6 = new PdfPCell(p6);
    cell6.setColspan(3);
    table1.addCell(cell6);
    Phrase p7 = new Phrase("3,660 ", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
    PdfPCell cell7 = new PdfPCell(p7);
    cell7.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell7.setHorizontalAlignment(Element.ALIGN_CENTER);
    table1.addCell(cell7);
    Phrase p8 = new Phrase("7,660", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
    PdfPCell cell8 = new PdfPCell(p8);
    cell8.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell8.setHorizontalAlignment(Element.ALIGN_CENTER);
    table1.addCell(cell8);
    Phrase p9 = new Phrase("2.", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
    PdfPCell cell9 = new PdfPCell(p9);
    cell9.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell9.setHorizontalAlignment(Element.ALIGN_CENTER);
    table1.addCell(cell9);
    Phrase p10 =
        new Phrase("M.E / M.TECH. / M.Phil ", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
    PdfPCell cell10 = new PdfPCell(p10);
    cell10.setColspan(5);
    table1.addCell(cell10);
    Phrase p11 = new Phrase("  ", new Font(FontFamily.TIMES_ROMAN, 10));
    PdfPCell cell11 = new PdfPCell(p11);
    cell11.setRowspan(4);
    cell11.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell11.setHorizontalAlignment(Element.ALIGN_CENTER);
    table1.addCell(cell11);
    Phrase p12 =
        new Phrase(
            "(A) P.G Gate Students\n"
                + "(B) P.G Non-Gate Students\n"
                + "(C) P.G Sponsored (Full-Time)\n"
                + " (2 Years)\n"
                + "(D) P.G Sponsored (Part-Time)\n"
                + " (3 Years)",
            new Font(FontFamily.TIMES_ROMAN, 9));
    PdfPCell cell12 = new PdfPCell(p12);
    cell12.setRowspan(4);
    cell12.setColspan(3);
    table1.addCell(cell12);
    Phrase p13 = new Phrase("3,660 ", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
    PdfPCell cell13 = new PdfPCell(p13);
    cell13.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell13.setHorizontalAlignment(Element.ALIGN_CENTER);
    table1.addCell(cell13);
    Phrase p14 = new Phrase("8,660 ", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
    PdfPCell cell14 = new PdfPCell(p14);
    cell14.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell14.setHorizontalAlignment(Element.ALIGN_CENTER);
    table1.addCell(cell14);
    Phrase p15 = new Phrase("6,160 ", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
    PdfPCell cell15 = new PdfPCell(p15);
    cell15.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell15.setHorizontalAlignment(Element.ALIGN_CENTER);
    table1.addCell(cell15);
    Phrase p16 = new Phrase("11,160 ", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
    PdfPCell cell16 = new PdfPCell(p16);
    cell16.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell16.setHorizontalAlignment(Element.ALIGN_CENTER);
    table1.addCell(cell16);
    Phrase p17 = new Phrase("20,960 ", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
    PdfPCell cell17 = new PdfPCell(p17);
    cell17.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell17.setHorizontalAlignment(Element.ALIGN_CENTER);
    table1.addCell(cell17);
    Phrase p18 = new Phrase("20,960 ", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
    PdfPCell cell18 = new PdfPCell(p18);
    cell18.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell18.setHorizontalAlignment(Element.ALIGN_CENTER);
    table1.addCell(cell18);
    Phrase p19 = new Phrase("17,460 ", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
    PdfPCell cell19 = new PdfPCell(p19);
    cell19.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell19.setHorizontalAlignment(Element.ALIGN_CENTER);
    table1.addCell(cell19);
    Phrase p20 = new Phrase("17,460 ", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
    PdfPCell cell20 = new PdfPCell(p20);
    cell20.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell20.setHorizontalAlignment(Element.ALIGN_CENTER);
    table1.addCell(cell20);
    Phrase p21 = new Phrase("B. Additional Fee ", new Font(FontFamily.TIMES_ROMAN, 10));
    PdfPCell cell21 = new PdfPCell(p21);
    cell21.setColspan(6);
    cell21.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell21.setHorizontalAlignment(Element.ALIGN_CENTER);
    table1.addCell(cell21);
    Phrase p22 = new Phrase("1.", new Font(FontFamily.TIMES_ROMAN, 10));
    PdfPCell cell22 = new PdfPCell(p22);
    cell22.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell22.setHorizontalAlignment(Element.ALIGN_CENTER);
    table1.addCell(cell22);

    Phrase p123 =
        new Phrase(
            " For all UG/PG,(Full Time)-Industrial Visit", new Font(FontFamily.TIMES_ROMAN, 10));
    PdfPCell cell123 = new PdfPCell(p123);
    cell123.setColspan(3);
    table1.addCell(cell123);

    Phrase p221 = new Phrase("2.", new Font(FontFamily.TIMES_ROMAN, 10));
    PdfPCell cell221 = new PdfPCell(p221);
    cell221.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell221.setHorizontalAlignment(Element.ALIGN_CENTER);

    Phrase p231 =
        new Phrase(
            "For B.E.(Aero) \n " + "VII Semester Flight Training Fee",
            new Font(FontFamily.TIMES_ROMAN, 10));
    PdfPCell cell231 = new PdfPCell(p231);
    cell231.setColspan(3);

    Phrase p2211 = new Phrase("3.", new Font(FontFamily.TIMES_ROMAN, 10));
    PdfPCell cell2211 = new PdfPCell(p2211);
    cell2211.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell2211.setHorizontalAlignment(Element.ALIGN_CENTER);
    Phrase p23 = new Phrase("Fine ", new Font(FontFamily.TIMES_ROMAN, 10));
    PdfPCell cell23 = new PdfPCell(p23);
    cell23.setColspan(3);

    Phrase p26 = new Phrase("4.", new Font(FontFamily.TIMES_ROMAN, 10));
    PdfPCell cell26 = new PdfPCell(p26);
    cell26.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell26.setHorizontalAlignment(Element.ALIGN_CENTER);

    Phrase p27 = new Phrase("Re-admission Fee ", new Font(FontFamily.TIMES_ROMAN, 10));
    PdfPCell cell27 = new PdfPCell(p27);
    cell27.setColspan(3);
    //  table1.addCell(cell27);

    Phrase p30 = new Phrase(" ", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
    PdfPCell cell30 = new PdfPCell(p30);
    cell30.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell30.setHorizontalAlignment(Element.ALIGN_CENTER);
    // table1.addCell(cell30);
    Phrase p31 = new Phrase("Total (A+B) ", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
    PdfPCell cell31 = new PdfPCell(p31);
    cell31.setColspan(3);
    cell31.setHorizontalAlignment(Element.ALIGN_RIGHT);
    // table1.addCell(cell31);
    int f = 0, rf = 0;
    int t = tot(ca, f, rf, b, s);
    Paragraph paf = new Paragraph();
    paf.add(new Chunk(String.valueOf(f), new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD)));
    Paragraph parf = new Paragraph();
    parf.add(new Chunk(String.valueOf(rf), new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD)));
    Paragraph pat = new Paragraph();
    pat.add(new Chunk(String.valueOf(t), new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD)));

    if (ca.equals("sc")
        || ca.equals("st")
        || ca.equals("da")
        || ca.equals("fg")
        || ca.equals("SC")
        || ca.equals("ST")
        || ca.equals("DA")
        || ca.equals("FG")) {

      Phrase p124 = new Phrase(" 500  ", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
      PdfPCell cell124 = new PdfPCell(p124);
      cell124.setVerticalAlignment(Element.ALIGN_MIDDLE);
      cell124.setHorizontalAlignment(Element.ALIGN_CENTER);
      table1.addCell(cell124);

      Phrase p125 = new Phrase("  ", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
      PdfPCell cell125 = new PdfPCell(p125);
      cell125.setVerticalAlignment(Element.ALIGN_MIDDLE);
      cell125.setHorizontalAlignment(Element.ALIGN_CENTER);
      table1.addCell(cell125);

      table1.addCell(cell221);
      table1.addCell(cell231);
      if (b.equals("aero") || b.equals("aeronautical engineering") && s == 7) {
        Phrase p241 = new Phrase("1000 ", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));

        PdfPCell cell241 = new PdfPCell(p241);
        cell241.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell241.setHorizontalAlignment(Element.ALIGN_CENTER);
        table1.addCell(cell241);

        Phrase p251 = new Phrase("  ", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
        PdfPCell cell251 = new PdfPCell(p251);
        cell251.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell251.setHorizontalAlignment(Element.ALIGN_CENTER);
        table1.addCell(cell251);
      } else {
        Phrase p241 = new Phrase(" ", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));

        PdfPCell cell241 = new PdfPCell(p241);
        cell241.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell241.setHorizontalAlignment(Element.ALIGN_CENTER);
        table1.addCell(cell241);

        Phrase p251 = new Phrase("  ", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
        PdfPCell cell251 = new PdfPCell(p251);
        cell251.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell251.setHorizontalAlignment(Element.ALIGN_CENTER);
        table1.addCell(cell251);
      }
      table1.addCell(cell2211);
      table1.addCell(cell23);
      // Phrase p24 = new Phrase("f ",new Font(FontFamily.TIMES_ROMAN, 10,Font.BOLD));
      PdfPCell cell24 = new PdfPCell(paf);
      cell24.setVerticalAlignment(Element.ALIGN_MIDDLE);
      cell24.setHorizontalAlignment(Element.ALIGN_CENTER);
      table1.addCell(cell24);

      Phrase p25 = new Phrase(" ", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
      PdfPCell cell25 = new PdfPCell(p25);
      cell25.setVerticalAlignment(Element.ALIGN_MIDDLE);
      cell25.setHorizontalAlignment(Element.ALIGN_CENTER);
      table1.addCell(cell25);

      table1.addCell(cell26);
      table1.addCell(cell27);

      // Phrase p28 = new Phrase(" rf ",new Font(FontFamily.TIMES_ROMAN, 10,Font.BOLD));
      PdfPCell cell28 = new PdfPCell(parf);
      cell28.setVerticalAlignment(Element.ALIGN_MIDDLE);
      cell28.setHorizontalAlignment(Element.ALIGN_CENTER);
      table1.addCell(cell28);

      Phrase p29 = new Phrase("  ", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
      PdfPCell cell29 = new PdfPCell(p29);
      cell29.setVerticalAlignment(Element.ALIGN_MIDDLE);
      cell29.setHorizontalAlignment(Element.ALIGN_CENTER);
      table1.addCell(cell29);
      table1.addCell(cell30);
      table1.addCell(cell31);

      PdfPCell cell32 = new PdfPCell(pat);
      cell32.setVerticalAlignment(Element.ALIGN_MIDDLE);
      cell32.setHorizontalAlignment(Element.ALIGN_CENTER);
      Phrase p33 = new Phrase("  ", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
      PdfPCell cell33 = new PdfPCell(p33);
      cell33.setVerticalAlignment(Element.ALIGN_MIDDLE);
      cell33.setHorizontalAlignment(Element.ALIGN_CENTER);
      table1.addCell(cell32);
      table1.addCell(cell33);
    } else {
      Phrase p124 = new Phrase(" ", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
      PdfPCell cell124 = new PdfPCell(p124);
      cell124.setVerticalAlignment(Element.ALIGN_MIDDLE);
      cell124.setHorizontalAlignment(Element.ALIGN_CENTER);
      table1.addCell(cell124);

      Phrase p125 = new Phrase("500 ", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
      PdfPCell cell125 = new PdfPCell(p125);
      cell125.setVerticalAlignment(Element.ALIGN_MIDDLE);
      cell125.setHorizontalAlignment(Element.ALIGN_CENTER);
      table1.addCell(cell125);

      table1.addCell(cell221);
      table1.addCell(cell231);
      if (b.equals("aero") || b.equals("aeronautical engineering") && s == 7) {
        Phrase p241 = new Phrase(" ", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));

        PdfPCell cell241 = new PdfPCell(p241);
        cell241.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell241.setHorizontalAlignment(Element.ALIGN_CENTER);
        table1.addCell(cell241);

        Phrase p251 = new Phrase(" 1000 ", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
        PdfPCell cell251 = new PdfPCell(p251);
        cell251.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell251.setHorizontalAlignment(Element.ALIGN_CENTER);
        table1.addCell(cell251);
      } else {
        Phrase p241 = new Phrase(" ", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));

        PdfPCell cell241 = new PdfPCell(p241);
        cell241.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell241.setHorizontalAlignment(Element.ALIGN_CENTER);
        table1.addCell(cell241);

        Phrase p251 = new Phrase("  ", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
        PdfPCell cell251 = new PdfPCell(p251);
        cell251.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell251.setHorizontalAlignment(Element.ALIGN_CENTER);
        table1.addCell(cell251);
      }
      table1.addCell(cell2211);
      table1.addCell(cell23);
      Phrase p24 = new Phrase(" ", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
      PdfPCell cell24 = new PdfPCell(p24);
      cell24.setVerticalAlignment(Element.ALIGN_MIDDLE);
      cell24.setHorizontalAlignment(Element.ALIGN_CENTER);
      table1.addCell(cell24);

      // Phrase p25 = new Phrase("f ",new Font(FontFamily.TIMES_ROMAN, 10,Font.BOLD));
      PdfPCell cell25 = new PdfPCell(paf);
      cell25.setVerticalAlignment(Element.ALIGN_MIDDLE);
      cell25.setHorizontalAlignment(Element.ALIGN_CENTER);
      table1.addCell(cell25);

      table1.addCell(cell26);
      table1.addCell(cell27);

      Phrase p28 = new Phrase("  ", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
      PdfPCell cell28 = new PdfPCell(p28);
      cell28.setVerticalAlignment(Element.ALIGN_MIDDLE);
      cell28.setHorizontalAlignment(Element.ALIGN_CENTER);
      table1.addCell(cell28);

      // Phrase p29 = new Phrase(" rf ",new Font(FontFamily.TIMES_ROMAN, 10,Font.BOLD));
      PdfPCell cell29 = new PdfPCell(parf);
      cell29.setVerticalAlignment(Element.ALIGN_MIDDLE);
      cell29.setHorizontalAlignment(Element.ALIGN_CENTER);
      table1.addCell(cell29);
      table1.addCell(cell30);
      table1.addCell(cell31);

      PdfPCell cell32 =
          new PdfPCell(new Phrase("  ", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD)));
      cell32.setVerticalAlignment(Element.ALIGN_MIDDLE);
      cell32.setHorizontalAlignment(Element.ALIGN_CENTER);

      PdfPCell cell33 = new PdfPCell(pat);
      cell33.setVerticalAlignment(Element.ALIGN_MIDDLE);
      cell33.setHorizontalAlignment(Element.ALIGN_CENTER);
      table1.addCell(cell32);
      table1.addCell(cell33);
    }

    Phrase p34 =
        new Phrase(
            " If Fee is paid by Demand Draft then give following details:  ",
            new Font(FontFamily.TIMES_ROMAN, 9, Font.BOLD));
    PdfPCell cell34 = new PdfPCell(p34);
    cell34.setColspan(6);
    table1.addCell(cell34);
    Phrase p35 = new Phrase("DD No", new Font(FontFamily.TIMES_ROMAN, 9, Font.BOLD));
    PdfPCell cell35 = new PdfPCell(p35);
    cell35.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell35.setHorizontalAlignment(Element.ALIGN_CENTER);

    cell35.setBorder(Rectangle.BOTTOM);
    table1.addCell(cell35);
    Paragraph pa2 = new Paragraph();
    pa2.add(new Chunk(String.valueOf(dd), new Font(FontFamily.TIMES_ROMAN, 9, Font.BOLD)));
    PdfPCell cell36 = new PdfPCell(pa2);
    cell36.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell36.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell36.setBorder(Rectangle.BOTTOM);
    cell35.setBorder(Rectangle.LEFT);
    table1.addCell(cell36);
    Phrase p37 = new Phrase("Date", new Font(FontFamily.TIMES_ROMAN, 9, Font.BOLD));
    PdfPCell cell37 = new PdfPCell(p37);
    cell37.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell37.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell37.setBorder(Rectangle.BOTTOM);
    table1.addCell(cell37);
    // Paragraph pa3=new Paragraph();
    // pa3.add(new Chunk(String.valueOf(" "),new Font(FontFamily.TIMES_ROMAN, 9, Font.BOLD)));
    String dd_date = ddate.getDay() + "-" + ddate.getMonth() + "-" + ddate.getYear();
    PdfPCell cell38 =
        new PdfPCell(new Phrase(dd_date, new Font(FontFamily.TIMES_ROMAN, 9, Font.BOLD)));
    // cell38.setHorizontalAlignment();
    cell38.setBorder(Rectangle.BOTTOM);
    cell38.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell38.setPaddingTop(8);
    table1.addCell(cell38);
    Phrase p39 = new Phrase("Amount:   Rs.", new Font(FontFamily.TIMES_ROMAN, 9, Font.BOLD));
    PdfPCell cell39 = new PdfPCell(p39);
    Paragraph pa4 = new Paragraph();
    pa4.add(new Chunk(String.valueOf(damt), new Font(FontFamily.TIMES_ROMAN, 9, Font.BOLD)));
    cell39.setBorder(Rectangle.BOTTOM);
    table1.addCell(cell39);
    PdfPCell cell40 = new PdfPCell(pa4);
    cell40.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell40.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell40.setBorder(Rectangle.BOTTOM);

    cell40.setBorder(Rectangle.RIGHT);
    table1.addCell(cell40);
    PdfPCell cell41 =
        new PdfPCell(
            new Phrase(
                "Name of the Bank from which DD purchased ", new Font(FontFamily.TIMES_ROMAN, 10)));
    cell41.setColspan(6);
    table1.addCell(cell41);
    String nb = bn.toUpperCase();
    PdfPCell cell42 = new PdfPCell(new Phrase(nb, new Font(FontFamily.TIMES_ROMAN, 10)));
    cell42.setColspan(6);
    cell42.setHorizontalAlignment(Element.ALIGN_CENTER);
    table1.addCell(cell42);

    PdfPCell cell43 =
        new PdfPCell(
            new Paragraph(
                "If fee is paid by cash then give denomination on the back side"
                    + "\n"
                    + "Amount in Words"
                    + "\n\n"
                    + "(Rupees    "
                    + challanodd.ConvertNumberToText(t)
                    + "   only)",
                new Font(FontFamily.TIMES_ROMAN, 9)));
    cell43.setColspan(6);
    cell43.setRowspan(4);
    table1.addCell(cell43);
    PdfPCell cell44 =
        new PdfPCell(
            new Phrase("\n " + "Date of Payment:", new Font(FontFamily.TIMES_ROMAN, 9, Font.BOLD)));
    cell44.setColspan(3);
    Phrase p241 = new Phrase("  ", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
    PdfPCell cell241 = new PdfPCell(p241);
    cell241.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell241.setHorizontalAlignment(Element.ALIGN_CENTER);

    cell44.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell44.setBorder(PdfPCell.NO_BORDER);
    cell44.setBorder(Rectangle.BOTTOM);
    cell44.setVerticalAlignment(Element.ALIGN_BOTTOM);
    cell44.setHorizontalAlignment(Element.ALIGN_LEFT);

    table1.addCell(cell44);
    PdfPCell cell48 =
        new PdfPCell(
            new Phrase(
                "\n \n" + "Remitter's Signature ", new Font(FontFamily.TIMES_ROMAN, 9, Font.BOLD)));
    cell48.setColspan(3);
    cell48.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell48.setBorder(PdfPCell.NO_BORDER);
    cell48.setBorder(Rectangle.BOTTOM);

    table1.addCell(cell48);

    PdfPCell c11 =
        new PdfPCell(
            new Phrase("FOR USE OF BANK", new Font(FontFamily.TIMES_ROMAN, 11, Font.BOLD)));
    c11.setColspan(6);
    c11.setBorder(PdfPCell.NO_BORDER);
    table1.addCell(c11);

    PdfPCell c12 =
        new PdfPCell(
            new Phrase(
                "(DD/Cash for acknowledging the receipt of amount)",
                new Font(FontFamily.TIMES_ROMAN, 11)));
    c12.setColspan(6);
    c12.setBorder(PdfPCell.NO_BORDER);
    table1.addCell(c12);

    PdfPCell c14 = new PdfPCell(new Phrase(" "));
    c14.setColspan(6);
    c14.setBorder(PdfPCell.NO_BORDER);
    table1.addCell(c14);

    PdfPCell c15 = new PdfPCell(new Phrase("Date: ", new Font(FontFamily.TIMES_ROMAN, 11)));
    c15.setColspan(2);
    c15.setBorder(PdfPCell.NO_BORDER);
    c15.setBorder(Rectangle.BOTTOM);
    table1.addCell(c15);

    PdfPCell c16 =
        new PdfPCell(
            new Phrase(
                "Signature of the bank official with seal", new Font(FontFamily.TIMES_ROMAN, 11)));
    c16.setColspan(4);
    c16.setBorder(PdfPCell.NO_BORDER);
    c16.setBorder(Rectangle.BOTTOM);
    table1.addCell(c16);

    PdfPCell c17 =
        new PdfPCell(
            new Phrase(
                "*Applicable for M.Sc. & M.Phil. also\n"
                    + "+Differently Abled (DA) students\n"
                    + "#First Graduate (FG) applicable for UG only",
                new Font(FontFamily.TIMES_ROMAN, 11)));
    c17.setColspan(6);
    c17.setBorder(PdfPCell.NO_BORDER);
    table1.addCell(c17);

    PdfPCell c18 =
        new PdfPCell(
            new Phrase(
                "The Collecting Bank is requested to feed the Student Roll no and course Details and Name of the Student Correctly.",
                new Font(FontFamily.TIMES_ROMAN, 11, Font.BOLD)));
    c18.setColspan(6);
    c18.setBorder(PdfPCell.NO_BORDER);
    table1.addCell(c18);

    // document.add(table1);
    return table1;
  }
  private static boolean createSingleAccounting(
      Document accountingDocument, PdfWriter writer, ArrayList<ShiftInstance> shifts, int pageNr) {
    boolean success = false;
    PersonalData personalData;
    float timeSumAsFloat = 0;
    DecimalFormat euroFormat = new DecimalFormat("#0.00");
    float salarySum = 0;
    try {
      personalData = PersonalData.getInstance();
      Font helveticaFont5 = FontFactory.getFont(FontFactory.HELVETICA, 5);
      Font helveticaFont6 = FontFactory.getFont(FontFactory.HELVETICA, 6);
      Font helveticaFont7 = FontFactory.getFont(FontFactory.HELVETICA, 7);
      Font helveticaFont7Bold = FontFactory.getFont(FontFactory.HELVETICA_BOLD, 7);
      Font helveticaFont8 = FontFactory.getFont(FontFactory.HELVETICA, 8);
      Font helveticaFont8Bold = FontFactory.getFont(FontFactory.HELVETICA_BOLD, 8);
      Font helveticaFont9 = FontFactory.getFont(FontFactory.HELVETICA, 9);
      Font helveticaFont10 = FontFactory.getFont(FontFactory.HELVETICA, 10);
      Font helveticaFont9Bold = FontFactory.getFont(FontFactory.HELVETICA_BOLD, 9);
      Font helveticaFont10Bold = FontFactory.getFont(FontFactory.HELVETICA_BOLD, 10);
      Font helveticaFont11Bold = FontFactory.getFont(FontFactory.HELVETICA_BOLD, 11);
      Font helveticaFont18Bold = FontFactory.getFont(FontFactory.HELVETICA_BOLD, 18);
      PdfPTable table1 = new PdfPTable(3);
      table1.setWidthPercentage(100);
      float[] table1CellWidth = new float[] {18f, 48f, 20f};
      table1.setWidths(table1CellWidth);
      PdfPCell cell1 = new PdfPCell();
      cell1.addElement(new Paragraph("DRK Freiburg\nRettungsdienst Freiburg", helveticaFont8));
      cell1.setVerticalAlignment(Element.ALIGN_TOP);
      cell1.setFixedHeight(27f);
      cell1.setPaddingTop(0);
      cell1.setBorderWidth(1);
      Image drkLogo = Image.getInstance(MainWindow.class.getResource("logo_Abrechnung.jpg"));
      drkLogo.scaleAbsolute(115f, 14f);
      drkLogo.setAbsolutePosition(441f, 784f);
      PdfPCell cell2 =
          new PdfPCell(new Paragraph("Abrechnung AK-RD/Aushilfen", helveticaFont18Bold));
      cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
      cell2.setVerticalAlignment(Element.ALIGN_MIDDLE);
      cell2.setPaddingBottom(6);
      cell2.setBorderWidth(1);
      cell2.setRowspan(2);
      PdfPCell cell3 = new PdfPCell();
      cell3.setBorderWidth(1);
      PdfPCell cell1p1 = new PdfPCell();
      cell1p1.setFixedHeight(10f);
      cell1p1.setPaddingTop(0);
      cell1p1.addElement(new Paragraph("Gültig ab: 01.06.2013", helveticaFont8));
      cell1p1.setHorizontalAlignment(Element.ALIGN_LEFT);
      cell1p1.setVerticalAlignment(Element.ALIGN_TOP);
      cell1p1.setBorderWidth(1);
      PdfPCell cell2p1 = new PdfPCell();
      cell2p1.setPaddingTop(0);
      cell2p1.addElement(new Paragraph("Ablage: Personalservice", helveticaFont8));
      cell2p1.setHorizontalAlignment(Element.ALIGN_RIGHT);
      cell2p1.setVerticalAlignment(Element.ALIGN_TOP);
      cell2p1.setBorderWidth(1);

      table1.addCell(cell1);
      table1.addCell(cell2);
      table1.addCell(cell3);
      table1.addCell(cell1p1);
      table1.addCell(cell2p1);
      // table1.addCell(cell1p1);
      // create empty line
      PdfPTable table2 = new PdfPTable(1);
      table2.setWidthPercentage(100);
      PdfPCell cellEmpty = new PdfPCell();
      cellEmpty.setMinimumHeight(6f);
      cellEmpty.setBorder(Rectangle.NO_BORDER);
      table2.addCell(cellEmpty);

      // set headlines for checkboxes
      PdfPTable table3 = new PdfPTable(5);
      table3.setWidthPercentage(100);
      PdfPCell cell4 = new PdfPCell(new Paragraph("  RD Freiburg", helveticaFont9Bold));
      cell4.setVerticalAlignment(Element.ALIGN_MIDDLE);
      cell4.setMinimumHeight(18f);
      cell4.setUseBorderPadding(true);
      PdfPCell cell5 = new PdfPCell(new Paragraph("  KTP Freiburg", helveticaFont9Bold));
      cell5.setVerticalAlignment(Element.ALIGN_MIDDLE);
      cell5.setUseBorderPadding(true);
      PdfPCell cell6 = new PdfPCell(new Paragraph("  RD Aussenwache", helveticaFont9Bold));
      cell6.setVerticalAlignment(Element.ALIGN_MIDDLE);
      cell6.setUseBorderPadding(true);
      PdfPCell cell7 = new PdfPCell(new Paragraph("  Sanitätsdienste", helveticaFont9Bold));
      cell7.setVerticalAlignment(Element.ALIGN_MIDDLE);
      cell7.setUseBorderPadding(true);
      PdfPCell cell8 = new PdfPCell(new Paragraph("  KVS Freiburg", helveticaFont9Bold));
      cell8.setVerticalAlignment(Element.ALIGN_MIDDLE);
      cell8.setUseBorderPadding(true);
      // set checkboxcells
      PdfPCell cell9 = new PdfPCell();
      cell9.setMinimumHeight(92f);
      PdfPCell cell10 = new PdfPCell();
      PdfPCell cell11 = new PdfPCell();
      PdfPCell cell12 = new PdfPCell();
      PdfPCell cell13 = new PdfPCell();
      PdfPCell cell14 = new PdfPCell(new Paragraph("KoSt.: 964001", helveticaFont9Bold));
      cell14.setFixedHeight(18f);
      PdfPCell cell15 = new PdfPCell(new Paragraph("KoSt.: 962100", helveticaFont9Bold));
      PdfPCell cell16 = new PdfPCell(new Paragraph("KoSt.: 9640 - X", helveticaFont9Bold));
      PdfPCell cell17 = new PdfPCell(new Paragraph("KoSt.: 3653 - X", helveticaFont9Bold));
      PdfPCell cell18 = new PdfPCell(new Paragraph("KoSt.: 973100", helveticaFont9Bold));

      table3.addCell(cell4);
      table3.addCell(cell5);
      table3.addCell(cell6);
      table3.addCell(cell7);
      table3.addCell(cell8);
      table3.addCell(cell9);
      table3.addCell(cell10);
      table3.addCell(cell11);
      table3.addCell(cell12);
      table3.addCell(cell13);
      table3.addCell(cell14);
      table3.addCell(cell15);
      table3.addCell(cell16);
      table3.addCell(cell17);
      table3.addCell(cell18);

      // checkboxes
      String[][] KoSt = new String[5][];
      // RD Freiburg
      KoSt[0] =
          new String[] {
            "RH ("
                + UtilityBox.salaryPerHourString(
                    ShiftContainer.ShiftType.RTW, PersonalData.Qualification.RH)
                + " €/h)",
            "RS ("
                + UtilityBox.salaryPerHourString(
                    ShiftContainer.ShiftType.RTW, PersonalData.Qualification.RS)
                + " €/h)",
            "RA ("
                + UtilityBox.salaryPerHourString(
                    ShiftContainer.ShiftType.RTW, PersonalData.Qualification.RA)
                + " €/h)"
          };
      // KTP Freiburg
      KoSt[1] = KoSt[0];
      // RD Aussenwache
      KoSt[2] =
          new String[] {
            /*"Baby-NAW - 01", */
            "Breisach - 03",
            "Kirchzarten - 10",
            "RH ("
                + UtilityBox.salaryPerHourString(
                    ShiftContainer.ShiftType.BREISACH, PersonalData.Qualification.RH)
                + " €/h)",
            "RS ("
                + UtilityBox.salaryPerHourString(
                    ShiftContainer.ShiftType.BREISACH, PersonalData.Qualification.RS)
                + " €/h)",
            "RA ("
                + UtilityBox.salaryPerHourString(
                    ShiftContainer.ShiftType.BREISACH, PersonalData.Qualification.RA)
                + " €/h)"
          };
      // Sanitätsdienste
      KoSt[3] =
          new String[] {
            "Veranstaltung - 01",
            "SC-Freiburg - 02",
            "Konzerthaus - 03",
            "RH ("
                + UtilityBox.salaryPerHourString(
                    ShiftContainer.ShiftType.EVENT, PersonalData.Qualification.RH)
                + " €/h)",
            "RS ("
                + UtilityBox.salaryPerHourString(
                    ShiftContainer.ShiftType.EVENT, PersonalData.Qualification.RS)
                + " €/h)",
            "RA ("
                + UtilityBox.salaryPerHourString(
                    ShiftContainer.ShiftType.EVENT, PersonalData.Qualification.RA)
                + " €/h)"
          };
      // KVS Freiburg
      KoSt[4] =
          new String[] {
            "RH-RA ("
                + UtilityBox.salaryPerHourString(
                    ShiftContainer.ShiftType.KVS, PersonalData.Qualification.RH)
                + " €/h)"
          };
      boolean[] boolArray = new boolean[] {false, false, false, false, false, false};
      int checkboxSetter;
      switch (PersonalData.getInstance().getQualification()) {
        case RH:
          checkboxSetter = 0;
          break;
        case RS:
          checkboxSetter = 1;
          break;
        case RA:
          checkboxSetter = 2;
          break;
        default:
          checkboxSetter = 0;
      }
      int accountType;
      String costUnit;
      switch (shifts.get(0).getType()) {
        case RTW:
        case HINTERGRUND:
          accountType = 0;
          costUnit = "964001";
          break;
        case ELW:
          accountType = 0;
          costUnit = "964001";
          break;
        case KTW:
          accountType = 1;
          costUnit = "962100";
          break;
        case EVENT:
          accountType = 3;
          costUnit = "3653";
          break;
        case SC:
          accountType = 3;
          costUnit = "3653";
          break;
        case CONCERT_HALL:
          accountType = 3;
          costUnit = "3653";
          break;
        case KVS:
          accountType = 4;
          checkboxSetter = 0;
          costUnit = "973100";
          break;
        default: // Außenwache
          accountType = 2;
          costUnit = "9640";
      }
      int xPosition = 46;
      for (int i = 0; i < KoSt.length; i++) {
        if (accountType == i) {
          if (i == 2) { // Außenwache
            switch (shifts.get(0).getType()) {
              case BREISACH:
                boolArray[0] = true;
                costUnit = costUnit + "03 (RD Breisach)";
                break;
              default:
                boolArray[1] = true;
                costUnit = costUnit + "10 (RD Kirchzarten)";
            }
            boolArray[checkboxSetter + 2] = true;
          } else if (i == 3) { // Sandienst etc.
            switch (shifts.get(0).getType()) {
              case SC:
                boolArray[1] = true;
                boolArray[checkboxSetter + 3] = true;
                costUnit = costUnit + "02 (SC-Freiburg)";
                break;
              case EVENT:
                boolArray[0] = true;
                boolArray[checkboxSetter + 3] = true;
                costUnit = costUnit + "01 (Veranstaltung)";
                break;
              default: // CONCERT_HALL
                boolArray[2] = true;
                costUnit = costUnit + "03 (Konzerthaus, 8,50 €/h)";
                break;
            }
          } else {
            boolArray[checkboxSetter] = true;
          }
        }
        createCheckbox(
            writer, accountingDocument, helveticaFont9, KoSt[i], xPosition, 736, boolArray, pageNr);
        boolArray = new boolean[] {false, false, false, false, false, false};
        xPosition += 105;
      }

      // create another empty line
      PdfPTable table4 = new PdfPTable(1);
      table4.setWidthPercentage(100);
      PdfPCell cellEmpty2 = new PdfPCell();
      cellEmpty2.setFixedHeight(5f);
      cellEmpty2.setBorder(Rectangle.NO_BORDER);
      table4.addCell(cellEmpty2);

      // create personal-data-table
      float personalDataCellHeight = 18f;
      Font personalDataFont = helveticaFont10Bold;
      PdfPTable table5 = new PdfPTable(5);
      table5.setWidthPercentage(100);
      table5.setWidths(new float[] {137f, 4f, 192f, 30f, 115f});
      String address = "Bekannt";
      // if address is not known put it into the form
      if (!personalData.addressKnown()) {
        address = personalData.getAddress();
      }
      String bankNameAndCity = "Bekannt";
      String accountNumber = "Bekannt";
      String blz = "Bekannt";
      if (!personalData.isDataKnown()) {
        bankNameAndCity = personalData.getBankNameAndCity();
        accountNumber = personalData.getAccountNumber();
        blz = Integer.toString(personalData.getBlz());
      }

      // name
      PdfPCell cell20 = new PdfPCell(new Paragraph("Name", personalDataFont));
      cell20.setFixedHeight(personalDataCellHeight);
      cell20.disableBorderSide(Rectangle.RIGHT);
      PdfPCell cell21 = new PdfPCell(new Paragraph(":", personalDataFont));
      cell21.disableBorderSide(Rectangle.LEFT);
      cell21.disableBorderSide(Rectangle.RIGHT);
      PdfPCell cell22 =
          new PdfPCell(
              new Paragraph(" " + personalData.getFirstName() + " " + personalData.getLastName()));
      cell22.setColspan(3);
      cell22.disableBorderSide(Rectangle.LEFT);
      // adress
      PdfPCell cell22p1 = new PdfPCell(new Paragraph("Adresse*", personalDataFont));
      cell22p1.setFixedHeight(personalDataCellHeight);
      cell22p1.disableBorderSide(Rectangle.RIGHT);
      PdfPCell cell22p2 = new PdfPCell(new Paragraph(":", personalDataFont));
      cell22p2.disableBorderSide(Rectangle.LEFT);
      cell22p2.disableBorderSide(Rectangle.RIGHT);
      PdfPCell cell22p3 = new PdfPCell(new Paragraph(" " + address));
      cell22p3.disableBorderSide(Rectangle.LEFT);
      cell22p3.setColspan(3);
      // bankname
      PdfPCell cell23 = new PdfPCell(new Paragraph("Bankname und Ort*", personalDataFont));
      cell23.setFixedHeight(personalDataCellHeight);
      cell23.disableBorderSide(Rectangle.RIGHT);
      PdfPCell cell24 = new PdfPCell(new Paragraph(":", personalDataFont));
      cell24.disableBorderSide(Rectangle.LEFT);
      cell24.disableBorderSide(Rectangle.RIGHT);
      PdfPCell cell25 = new PdfPCell(new Paragraph(" " + bankNameAndCity));
      cell25.disableBorderSide(Rectangle.LEFT);
      cell25.setColspan(3);
      // accountnr
      PdfPCell cell26 = new PdfPCell(new Paragraph("Kontonummer*", personalDataFont));
      cell26.setFixedHeight(personalDataCellHeight);
      cell26.disableBorderSide(Rectangle.RIGHT);
      PdfPCell cell27 = new PdfPCell(new Paragraph(":", personalDataFont));
      cell27.disableBorderSide(Rectangle.LEFT);
      cell27.disableBorderSide(Rectangle.RIGHT);
      PdfPCell cell28 = new PdfPCell(new Paragraph(" " + accountNumber));
      cell28.disableBorderSide(Rectangle.LEFT);
      cell28.disableBorderSide(Rectangle.RIGHT);
      PdfPCell cell29 = new PdfPCell(new Paragraph("BLZ :", personalDataFont));
      cell29.disableBorderSide(Rectangle.LEFT);
      cell29.disableBorderSide(Rectangle.RIGHT);
      PdfPCell cell2930 = new PdfPCell(new Paragraph(blz));
      cell2930.disableBorderSide(Rectangle.LEFT);

      PdfPCell cell30 = new PdfPCell(new Paragraph("zu belastende Kostenstelle", personalDataFont));
      cell30.setFixedHeight(personalDataCellHeight);
      cell30.disableBorderSide(Rectangle.RIGHT);
      PdfPCell cell3031 = new PdfPCell(new Paragraph(":", personalDataFont));
      cell3031.disableBorderSide(Rectangle.LEFT);
      cell3031.disableBorderSide(Rectangle.RIGHT);
      PdfPCell cell3032 = new PdfPCell(new Paragraph(" " + costUnit));
      cell3032.disableBorderSide(Rectangle.LEFT);
      cell3032.setColspan(3);

      table5.addCell(cell20);
      table5.addCell(cell21);
      table5.addCell(cell22);
      table5.addCell(cell22p1);
      table5.addCell(cell22p2);
      table5.addCell(cell22p3);
      table5.addCell(cell23);
      table5.addCell(cell24);
      table5.addCell(cell25);
      table5.addCell(cell26);
      table5.addCell(cell27);
      table5.addCell(cell28);
      table5.addCell(cell29);
      table5.addCell(cell2930);
      table5.addCell(cell30);
      table5.addCell(cell3031);
      table5.addCell(cell3032);

      // set textline
      PdfPTable table6 = new PdfPTable(1);
      table6.setWidthPercentage(100);
      PdfPCell cell31 =
          new PdfPCell(
              new Paragraph("* Angabe nur bei Neueinstellung oder Veränderungen", helveticaFont8));
      cell31.setFixedHeight(12f);
      cell31.setBorder(Rectangle.NO_BORDER);
      table6.addCell(cell31);

      // set the shift table
      PdfPTable table7 = new PdfPTable(10);
      table7.setWidthPercentage(100);
      table7.setWidths(
          new float[] {1.96f, 0.9f, 1.8f, 1.8f, 2.9f, 1.96f, 1.96f, 1.85f, 1.85f, 2.2f});
      // headlines
      Font shiftTableHeadlineFont = helveticaFont8Bold;
      PdfPCell cell32 = new PdfPCell(new Paragraph("Datum", shiftTableHeadlineFont));
      cell32.setFixedHeight(50f);
      cell32.setVerticalAlignment(Rectangle.ALIGN_MIDDLE);
      cell32.setHorizontalAlignment(Rectangle.ALIGN_CENTER);

      PdfPCell cell33 = new PdfPCell(new Paragraph("Tag", shiftTableHeadlineFont));
      cell33.setVerticalAlignment(Rectangle.ALIGN_MIDDLE);
      cell33.setHorizontalAlignment(Rectangle.ALIGN_CENTER);
      PdfPCell cell34 = new PdfPCell(new Paragraph("Uhrzeit\nvon", shiftTableHeadlineFont));
      cell34.setVerticalAlignment(Rectangle.ALIGN_MIDDLE);
      cell34.setHorizontalAlignment(Rectangle.ALIGN_CENTER);
      PdfPCell cell35 = new PdfPCell(new Paragraph("Uhrzeit\nbis", shiftTableHeadlineFont));
      cell35.setVerticalAlignment(Rectangle.ALIGN_MIDDLE);
      cell35.setHorizontalAlignment(Rectangle.ALIGN_CENTER);
      PdfPCell cell36 = new PdfPCell(new Paragraph("Besatzung", shiftTableHeadlineFont));
      cell36.setVerticalAlignment(Rectangle.ALIGN_MIDDLE);
      cell36.setHorizontalAlignment(Rectangle.ALIGN_CENTER);
      PdfPCell cell37 =
          new PdfPCell(new Paragraph("Anzahl geleisteter Stunden (Zeit)", shiftTableHeadlineFont));
      cell37.setVerticalAlignment(Rectangle.ALIGN_MIDDLE);
      cell37.setHorizontalAlignment(Rectangle.ALIGN_CENTER);
      PdfPCell cell38 =
          new PdfPCell(
              new Paragraph("Anzahl geleisteter Stunden (Dezimal)", shiftTableHeadlineFont));
      cell38.setVerticalAlignment(Rectangle.ALIGN_MIDDLE);
      cell38.setHorizontalAlignment(Rectangle.ALIGN_CENTER);
      PdfPCell cell39 = new PdfPCell(new Paragraph("€ pro\nStunde", shiftTableHeadlineFont));
      cell39.setVerticalAlignment(Rectangle.ALIGN_MIDDLE);
      cell39.setHorizontalAlignment(Rectangle.ALIGN_CENTER);
      PdfPCell cell40 = new PdfPCell(new Paragraph("€\ngesamt", shiftTableHeadlineFont));
      cell40.setVerticalAlignment(Rectangle.ALIGN_MIDDLE);
      cell40.setHorizontalAlignment(Rectangle.ALIGN_CENTER);
      PdfPCell cell41 = new PdfPCell(new Paragraph("Kommentar", shiftTableHeadlineFont));
      cell41.setVerticalAlignment(Rectangle.ALIGN_MIDDLE);
      cell41.setHorizontalAlignment(Rectangle.ALIGN_CENTER);

      table7.addCell(cell32);
      table7.addCell(cell33);
      table7.addCell(cell34);
      table7.addCell(cell35);
      table7.addCell(cell36);
      table7.addCell(cell37);
      table7.addCell(cell38);
      table7.addCell(cell39);
      table7.addCell(cell40);
      table7.addCell(cell41);

      float salary =
          UtilityBox.getInstance()
              .calculateSalaryPerHour(shifts.get(0), PersonalData.getInstance().getQualification());
      // begin shifttable
      for (int i = 0; i <= 12; i++) {
        ShiftInstance currentShift = null;
        String weekDay = "";
        String date = "";
        String startTimeAsString = "";
        String endTimeAsString = "";
        String partner = "";
        Font partnerFont = helveticaFont9;
        String timeInHours = "";
        String timeasFloat = "";
        String salaryPerHour = "";
        String shiftSalary = "";
        String commuteExpenses = "";
        String comment = "";
        Font commentFont = helveticaFont9;

        SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
        Calendar cal = Calendar.getInstance();
        if (shifts.size() > i) {
          currentShift = shifts.get(i);
          date = currentShift.getDateString();
          try {
            cal.setTime(sdf.parse(date));
            weekDay = UtilityBox.getDayOfWeekString(cal.get(Calendar.DAY_OF_WEEK));
          } catch (ParseException ex) {
            System.out.println(
                "Exception in PdfCreator.createAccounting "
                    + "(parsing date failed): "
                    + ex.getMessage());
          }
          int startTime = currentShift.getActualStartingTimeWithPrepTime();
          int endTime = currentShift.getActualEndTime();
          int breakTime = currentShift.getActualBreakTime();
          startTimeAsString = UtilityBox.createTimeStringFromInt(startTime);
          endTimeAsString = UtilityBox.createTimeStringFromInt(endTime);
          partner = currentShift.getPartner();
          if (partner.length() > 14) {
            if (partner.length() > 18) {
              partner = partner.substring(0, 18);
            }
            partnerFont = helveticaFont7;
          }
          timeInHours =
              UtilityBox.getInstance().calculateTimeInHours(startTime, endTime, breakTime);
          timeasFloat = euroFormat.format(currentShift.getTimeAsFloat());
          timeSumAsFloat += currentShift.getTimeAsFloat();
          salaryPerHour = euroFormat.format(salary) + " €";
          shiftSalary = euroFormat.format(currentShift.getTimeAsFloat() * salary) + " €";
          comment = currentShift.getComment();
          int commentLength = comment.length();
          if (commentLength > 10) {
            if (commentLength > 13) {
              if (commentLength > 36) {
                comment = comment.substring(0, 36);
              }
              commentFont = helveticaFont5;
            } else {
              commentFont = helveticaFont7;
            }
          }
        }

        PdfPCell tempCell = emptyPdfPCell();
        Paragraph content = new Paragraph(date, helveticaFont9);
        tempCell.addElement(content);
        tempCell.setFixedHeight(19f);
        table7.addCell(tempCell);
        tempCell = emptyPdfPCell();
        content = new Paragraph(weekDay, helveticaFont9);
        tempCell.addElement(content);
        table7.addCell(tempCell);
        tempCell = emptyPdfPCell();
        content = new Paragraph(startTimeAsString, helveticaFont9);
        tempCell.addElement(content);
        table7.addCell(tempCell);
        tempCell = emptyPdfPCell();
        content = new Paragraph(endTimeAsString, helveticaFont9);
        tempCell.addElement(content);
        table7.addCell(tempCell);
        tempCell = emptyPdfPCell();
        content = new Paragraph(partner, partnerFont);
        tempCell.addElement(content);
        table7.addCell(tempCell);
        tempCell = emptyPdfPCell();
        content = new Paragraph(timeInHours, helveticaFont9);
        tempCell.addElement(content);
        table7.addCell(tempCell);
        tempCell = emptyPdfPCell();
        content = new Paragraph(timeasFloat, helveticaFont9);
        tempCell.addElement(content);
        table7.addCell(tempCell);
        tempCell = emptyPdfPCell();
        content = new Paragraph(salaryPerHour, helveticaFont9);
        tempCell.addElement(content);
        table7.addCell(tempCell);
        tempCell = emptyPdfPCell();
        content = new Paragraph(shiftSalary, helveticaFont9);
        tempCell.addElement(content);
        table7.addCell(tempCell);
        tempCell = emptyPdfPCell();
        content = new Paragraph(comment, commentFont);
        tempCell.addElement(content);
        table7.addCell(tempCell);
      }
      // end of shift table
      // calculate the complete salary
      salarySum = timeSumAsFloat * salary;
      PdfPCell cell42 = emptyPdfPCell();
      cell42.setFixedHeight(20);
      cell42.setBorderWidth(2);
      cell42.setColspan(6);
      cell42.addElement(
          new Paragraph("Summe der geleisteten Stunden / Auszahlungsbetrag:", helveticaFont8Bold));
      cell42.setVerticalAlignment(Rectangle.ALIGN_MIDDLE);
      cell42.setPaddingBottom(6);
      PdfPCell cell43 =
          new PdfPCell(new Paragraph(euroFormat.format(timeSumAsFloat), helveticaFont9Bold));
      cell43.setVerticalAlignment(Rectangle.ALIGN_MIDDLE);
      cell43.setBorderWidthBottom(2);
      cell43.setBorderWidthTop(2);
      cell43.setBorderWidthLeft(2);
      PdfPCell cell44 =
          new PdfPCell(new Paragraph(euroFormat.format(salary) + " €", helveticaFont9Bold));
      cell44.setVerticalAlignment(Rectangle.ALIGN_MIDDLE);
      cell44.setBorderWidthBottom(2);
      cell44.setBorderWidthTop(2);
      PdfPCell cell45 =
          new PdfPCell(new Paragraph(euroFormat.format(salarySum) + " €", helveticaFont9Bold));
      cell45.setVerticalAlignment(Rectangle.ALIGN_MIDDLE);
      cell45.setColspan(1);
      cell45.setBorderWidthBottom(2);
      cell45.setBorderWidthTop(2);

      // commentcell
      PdfPCell cell461 = emptyPdfPCell();
      cell461.setColspan(2);
      cell461.setBorderWidthBottom(2);
      cell461.setBorderWidthTop(2);
      cell461.setBorderWidthRight(2);

      table7.addCell(cell42);
      table7.addCell(cell43);
      table7.addCell(cell44);
      table7.addCell(cell45);
      //      table7.addCell(cell46);
      table7.addCell(cell461);

      // another empty line
      PdfPTable table8 = new PdfPTable(1);
      table8.setWidthPercentage(100);
      PdfPCell cell47 = new PdfPCell();
      cell47.setFixedHeight(8);
      cell47.setBorder(Rectangle.NO_BORDER);
      table8.addCell(cell47);

      // sign-field
      PdfPTable table9 = new PdfPTable(1);
      table9.setWidthPercentage(100);
      String signatureString = "Unterschrift Mitarbeiter/in:";
      if (false) { // TODO: wenn version veraltet
        signatureString += " NICHT FREIGEGEBENE VERSION. NICHT ABGEBEN.";
      }
      PdfPCell cell48 = new PdfPCell(new Paragraph(signatureString, helveticaFont11Bold));
      cell48.setVerticalAlignment(Rectangle.ALIGN_MIDDLE);
      cell48.setFixedHeight(25);
      cell48.setBorderWidth(2);
      table9.addCell(cell48);

      // another empty line. We use table8 again.
      //
      PdfPTable table10 = new PdfPTable(3);
      table10.setWidthPercentage(100);
      table10.setWidths(new int[] {5, 6, 8});
      PdfPCell cell49 = new PdfPCell(new Paragraph("Eingang RDL", helveticaFont10));
      cell49.setVerticalAlignment(Rectangle.ALIGN_TOP);
      cell49.setHorizontalAlignment(Rectangle.ALIGN_LEFT);
      cell49.setBorderWidthBottom(0);
      cell49.setFixedHeight(48);
      PdfPCell cell50 = new PdfPCell(new Paragraph("Eingang Personalservice", helveticaFont10));
      cell50.setVerticalAlignment(Rectangle.ALIGN_TOP);
      cell50.setHorizontalAlignment(Rectangle.ALIGN_LEFT);
      cell50.setBorderWidthBottom(0);
      PdfPCell cell51 = new PdfPCell(new Paragraph("geprüft:", helveticaFont10));
      cell51.setVerticalAlignment(Rectangle.ALIGN_TOP);
      cell51.setHorizontalAlignment(Rectangle.ALIGN_LEFT);
      PdfPCell cell52 = new PdfPCell();
      cell52.setBorderWidthTop(0);
      cell52.setFixedHeight(48);

      PdfPCell cell53 = new PdfPCell();
      cell53.setBorderWidthTop(0);
      PdfPCell cell54 = new PdfPCell(new Paragraph("zur Zahlung angewiesen:", helveticaFont10));
      cell54.setVerticalAlignment(Rectangle.ALIGN_TOP);
      cell54.setHorizontalAlignment(Rectangle.ALIGN_LEFT);
      cell54.setFixedHeight(48);

      table10.addCell(cell49);
      table10.addCell(cell50);
      table10.addCell(cell51);
      table10.addCell(cell52);
      table10.addCell(cell53);
      table10.addCell(cell54);

      // add department-box
      float departmentBoxX = 345;
      float departmentBoxY = 123;
      float departmentBoxWidth = 103;
      float departmentBoxHeight = 28;
      float departmentBoxTextY = departmentBoxY + 20;
      PdfContentByte contentByte = writer.getDirectContent();
      contentByte.setLineWidth(.7f);
      contentByte.rectangle(
          departmentBoxX, departmentBoxY, departmentBoxWidth, departmentBoxHeight);
      contentByte.rectangle(
          departmentBoxX + departmentBoxWidth,
          departmentBoxY,
          departmentBoxWidth,
          departmentBoxHeight);
      contentByte.beginText();
      contentByte.setFontAndSize(BaseFont.createFont("Helvetica", "", false), 8);
      contentByte.showTextAligned(
          PdfContentByte.ALIGN_CENTER,
          "Dienstplanung",
          (int) (departmentBoxX + (departmentBoxWidth / 2)),
          departmentBoxTextY,
          0);
      contentByte.setFontAndSize(BaseFont.createFont("Helvetica", "", false), 8);
      contentByte.showTextAligned(
          PdfContentByte.ALIGN_CENTER,
          "bei SAN-Diensten Abt.RK",
          (int) (departmentBoxX + (departmentBoxWidth * 1.5)),
          departmentBoxTextY,
          0);
      contentByte.endText();

      // add payment order-box
      float paymentOrderBoxY = 75;
      float paymentOrderBoxTextY = paymentOrderBoxY + 20;
      contentByte.rectangle(
          departmentBoxX, paymentOrderBoxY, 2 * departmentBoxWidth, departmentBoxHeight);

      // use table8 for a empty line again
      // Version/Author
      PdfPTable table11 = new PdfPTable(4);
      table11.setWidthPercentage(100);
      table11.addCell(new PdfPCell(new Paragraph("Version 4.2", helveticaFont9)));
      table11.addCell(new PdfPCell(new Paragraph("geändert:", helveticaFont9)));
      table11.addCell(new PdfPCell(new Paragraph("Freigegeben:", helveticaFont9)));
      table11.addCell(new PdfPCell(new Paragraph("Seite 1 von 1", helveticaFont9)));
      table11.addCell(new PdfPCell(new Paragraph("Stand: 26.01.2015", helveticaFont9)));
      table11.addCell(new PdfPCell(new Paragraph("E. Willaredt, J. Güttler", helveticaFont9)));
      table11.addCell(new PdfPCell(new Paragraph("Karin Müller", helveticaFont9)));
      table11.addCell(new PdfPCell(new Paragraph("Personalservice", helveticaFont9)));

      // add tables to document
      accountingDocument.add(table1);
      accountingDocument.add(drkLogo);
      accountingDocument.add(table2);
      accountingDocument.add(table3);
      accountingDocument.add(table4);
      accountingDocument.add(table5);
      accountingDocument.add(table6);
      accountingDocument.add(table7);
      accountingDocument.add(table8);
      accountingDocument.add(table9);
      accountingDocument.add(table8);
      accountingDocument.add(table10);
      accountingDocument.add(table8);
      accountingDocument.add(table11);
      success = true;
      // TODO: for JDK7 use Multicatch
    } catch (Exception e) { // DocumentException | IOException | NullPointerException e) {
      success = false;
      UtilityBox.getInstance()
          .displayErrorPopup(
              "Abrechnung", "Fehler beim Erstellen der Abrechnung:\n" + e.getMessage());
    }
    return success;
  }
  private void pageHeader(PdfWriter writer)
      throws MalformedURLException, IOException, DocumentException {
    Integer colspan = 15;
    PdfPTable headerTable = newTable().columns(colspan).totalWidth(510F).o();

    // logo & start
    Image logo =
        Image.getInstance("pdf" + File.separator + "img" + File.separator + "logo_top_final.png");
    logo.scaleAbsolute(171f, 45f);
    logo.setAbsolutePosition(44, 760);
    writer.getDirectContent().addImage(logo);

    Phrase t1 = new Phrase("Statement / Tax Invoice", ITextFont.arial_normal_14);
    Phrase t2 =
        new Phrase(
            "GST Registration Number: " + this.getCompanyDetail().getGst_registration_number(),
            ITextFont.lucida_sans_unicode_9);
    PdfContentByte canvas = writer.getDirectContentUnder();
    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, t1, 44, 744, 0);
    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, t2, 44, 730, 0);

    /*
     * header table begin
     */
    addEmptyCol(headerTable, 34F, colspan);
    addCol(headerTable, this.getCompanyDetail().getName())
        .colspan(colspan)
        .font(ITextFont.arial_normal_8)
        .alignH("r")
        .o();
    addCol(headerTable, this.getCompanyDetail().getBilling_address())
        .colspan(colspan)
        .font(ITextFont.arial_normal_8)
        .alignH("r")
        .o();
    addCol(headerTable, "Tel: " + this.getCompanyDetail().getTelephone())
        .colspan(colspan)
        .font(ITextFont.arial_normal_8)
        .alignH("r")
        .o();
    addCol(headerTable, this.getCompanyDetail().getDomain())
        .colspan(colspan)
        .font(ITextFont.arial_normal_8)
        .alignH("r")
        .o();
    addCol(headerTable, " ")
        .colspan(colspan)
        .borderColor("b", titleBGColor)
        .borderWidth("b", 3F)
        .o();
    /*
     * header table end
     */
    /*
     * invoice basics begin
     */
    addEmptyCol(headerTable, 14F, colspan);
    addEmptyCol(headerTable, 4F, colspan - 4);
    addCol(headerTable, "Customer Id: ").colspan(2).font(ITextFont.arial_bold_8).o();
    addCol(headerTable, this.getCo().getCustomer_id().toString())
        .colspan(2)
        .font(ITextFont.arial_bold_8)
        .alignH("r")
        .o();
    addEmptyCol(headerTable, 4F, colspan - 4);
    addCol(headerTable, "Invoice No: ").colspan(2).font(ITextFont.arial_bold_8).o();
    addCol(headerTable, this.getEtc().getId().toString())
        .colspan(2)
        .font(ITextFont.arial_bold_8)
        .alignH("r")
        .o();
    addEmptyCol(headerTable, 4F, colspan - 4);
    addCol(headerTable, "Date: ").colspan(2).font(ITextFont.arial_bold_8).o();
    addCol(headerTable, TMUtils.retrieveMonthAbbrWithDate(this.getEtc().getCreate_date()))
        .colspan(2)
        .font(ITextFont.arial_bold_8)
        .alignH("r")
        .o();
    addEmptyCol(headerTable, colspan);

    /*
     * invoice basics end
     */
    // complete the table
    headerTable.completeRow();
    // write the table to an absolute position
    PdfContentByte paymentSlipTableCanvas = writer.getDirectContent();
    headerTable.writeSelectedRows(0, -1, 41, 810, paymentSlipTableCanvas);
  }
  public String create() throws DocumentException, MalformedURLException, IOException {
    Document document = new Document(PageSize.A4);

    // Output PDF Path, e.g.: early_termination_charge_60089.pdf
    String outputFile =
        TMUtils.createPath(
            "broadband"
                + File.separator
                + "customers"
                + File.separator
                + this.co.getCustomer_id()
                + File.separator
                + "early_termination_charge_"
                + this.getEtc().getId()
                + ".pdf");

    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(outputFile));
    document.open();

    /*
     *
     *  FIRST PAGE BEGIN
     *
     */
    super.setGlobalBorderWidth(globalBorderWidth);

    // BASIC INFO
    document.add(createCustomerBasicInfo());

    document.add(createEarlyTerminationChargeDetail());

    /*
     * PAYMENT SLIP TABLE BEGIN
     */

    // CARTOON
    Image cartoon =
        Image.getInstance("pdf" + File.separator + "img" + File.separator + "cartoon_done.png");
    cartoon.scaleAbsolute(80f, 40.5f);
    cartoon.setAbsolutePosition(50, 165);
    writer.getDirectContent().addImage(cartoon);

    { // createPaymentSlip
      PdfPTable paymentSlipTable = newTable().columns(5).totalWidth(535F).o();
      Image img =
          Image.getInstance(
              "pdf" + File.separator + "img" + File.separator + "scissor_separator.png");
      img.setWidthPercentage(100);
      addCol(paymentSlipTable, " ").colspan(5).image(img).o();

      // WHITE TITLE
      addEmptyRow(paymentSlipTable, 4);

      addCol(paymentSlipTable, "Payment Slip")
          .rowspan(4)
          .font(ITextFont.arial_bold_10)
          .paddingTo("t", 6F)
          .o();

      // LIGHT GRAY TITLE
      addCol(paymentSlipTable, " ")
          .bgColor(new BaseColor(234, 234, 234))
          .borderColor(BaseColor.WHITE)
          .border("r", 1F)
          .o();
      addCol(paymentSlipTable, " ")
          .bgColor(new BaseColor(234, 234, 234))
          .borderColor(BaseColor.WHITE)
          .border("r", 1F)
          .o();
      addCol(paymentSlipTable, " ").bgColor(new BaseColor(234, 234, 234)).o();

      // LIGHT GRAY CONTENT
      addCol(paymentSlipTable, "Customer ID")
          .font(ITextFont.arial_bold_8)
          .bgColor(new BaseColor(234, 234, 234))
          .borderColor(BaseColor.WHITE)
          .border("r", 1F)
          .indent(14F)
          .o();
      addCol(paymentSlipTable, "Invoice Number")
          .font(ITextFont.arial_bold_8)
          .bgColor(new BaseColor(234, 234, 234))
          .borderColor(BaseColor.WHITE)
          .border("r", 1F)
          .indent(14F)
          .o();
      addCol(paymentSlipTable, "Due Date")
          .font(ITextFont.arial_bold_8)
          .bgColor(new BaseColor(234, 234, 234))
          .indent(14F)
          .o();

      // LIGHT GRAY VALUE
      addCol(paymentSlipTable, this.getCo().getCustomer_id().toString())
          .font(ITextFont.arial_normal_6)
          .bgColor(new BaseColor(234, 234, 234))
          .borderColor(BaseColor.WHITE)
          .border("r", 1F)
          .paddingTo("t", 6F)
          .indent(14F)
          .o();
      addCol(paymentSlipTable, this.etc.getId().toString())
          .font(ITextFont.arial_normal_7)
          .bgColor(new BaseColor(234, 234, 234))
          .borderColor(BaseColor.WHITE)
          .border("r", 1F)
          .paddingTo("t", 6F)
          .indent(14F)
          .o();
      addCol(paymentSlipTable, TMUtils.retrieveMonthAbbrWithDate(this.etc.getDue_date()))
          .font(ITextFont.arial_normal_7)
          .bgColor(new BaseColor(234, 234, 234))
          .paddingTo("t", 6F)
          .indent(14F)
          .o();
      addCol(paymentSlipTable, " ")
          .bgColor(new BaseColor(234, 234, 234))
          .borderColor(BaseColor.WHITE)
          .border("r", 1F)
          .o();
      addCol(paymentSlipTable, " ")
          .bgColor(new BaseColor(234, 234, 234))
          .borderColor(BaseColor.WHITE)
          .border("r", 1F)
          .o();
      addCol(paymentSlipTable, " ").bgColor(new BaseColor(234, 234, 234)).o();

      // SEPARATOR BEGIN
      addEmptyCol(paymentSlipTable, 2F, 5);
      // SEPARATOR END

      // SECOND SECTION
      addCol(paymentSlipTable, "Paying By Direct Credit")
          .colspan(2)
          .font(ITextFont.arial_normal_8)
          .indent(4F)
          .o();
      addCol(paymentSlipTable, "Total amount due before")
          .rowspan(2)
          .font(ITextFont.arial_normal_white_8)
          .bgColor(totleChequeAmountBGColor)
          .paddingTo("t", 8F)
          .indent(14F)
          .o();
      addCol(paymentSlipTable, this.getEtc().getDue_date_str())
          .rowspan(2)
          .font(ITextFont.arial_normal_white_8)
          .bgColor(totleChequeAmountBGColor)
          .paddingTo("t", 8F)
          .indent(32F)
          .o();
      // input box begin
      addCol(
              paymentSlipTable,
              TMUtils.fillDecimalPeriod(String.valueOf(this.etc.getCharge_amount())))
          .rowspan(2)
          .font(ITextFont.arial_normal_8)
          .bgColor(BaseColor.WHITE)
          .borderColor(totleChequeAmountBGColor)
          .borderZoom(8F)
          .alignH("r")
          .o();
      // input box end
      addCol(paymentSlipTable, "Bank: " + this.getCompanyDetail().getBank_name())
          .colspan(2)
          .font(ITextFont.arial_normal_8)
          .indent(4F)
          .o();
      addCol(paymentSlipTable, "Name of Account: " + this.getCompanyDetail().getBank_account_name())
          .colspan(2)
          .font(ITextFont.arial_normal_8)
          .indent(4F)
          .o();
      addCol(paymentSlipTable, "Total amount due after")
          .rowspan(2)
          .font(ITextFont.arial_normal_white_8)
          .bgColor(totleChequeAmountBGColor)
          .paddingTo("t", 8F)
          .indent(14F)
          .o();
      addCol(paymentSlipTable, this.getEtc().getDue_date_str())
          .rowspan(2)
          .font(ITextFont.arial_normal_white_8)
          .bgColor(totleChequeAmountBGColor)
          .paddingTo("t", 8F)
          .indent(32F)
          .o();
      // input box begin
      addCol(
              paymentSlipTable,
              TMUtils.fillDecimalPeriod(String.valueOf(this.etc.getTotal_payable_amount())))
          .rowspan(2)
          .font(ITextFont.arial_normal_8)
          .bgColor(BaseColor.WHITE)
          .borderColor(totleChequeAmountBGColor)
          .borderZoom(8F)
          .alignH("r")
          .o();
      // input box end
      addCol(
              paymentSlipTable,
              "Account Number: " + this.getCompanyDetail().getBank_account_number())
          .colspan(2)
          .font(ITextFont.arial_normal_8)
          .indent(4F)
          .o();

      // THIRD SECTION
      addEmptyCol(paymentSlipTable, 1F, 5);

      // SEPARATOR BEGIN
      // SEPARATOR END

      addCol(paymentSlipTable, "Paying by cheques")
          .colspan(3)
          .font(ITextFont.arial_normal_white_8)
          .bgColor(totleChequeAmountBGColor)
          .paddingTo("t", 4F)
          .indent(4F)
          .o();
      addCol(paymentSlipTable, "ENCLOSED AMOUNT")
          .colspan(2)
          .font(ITextFont.arial_bold_white_10)
          .bgColor(totleChequeAmountBGColor)
          .paddingTo("t", 4F)
          .indent(40F)
          .o();
      addCol(
              paymentSlipTable,
              "Please make cheques payable to " + this.companyDetail.getName() + " and")
          .colspan(3)
          .font(ITextFont.arial_normal_white_8)
          .bgColor(totleChequeAmountBGColor)
          .indent(4F)
          .o();

      // BEGIN BOX
      addCol(paymentSlipTable, " ")
          .colspan(2)
          .rowspan(4)
          .bgColor(BaseColor.WHITE)
          .paddingTo("l", 42F)
          .paddingTo("t", 6F)
          .borderColor(totleChequeAmountBGColor)
          .border("r", 20F)
          .o();
      // END BOX

      addCol(paymentSlipTable, "write your Name and Phone Number on the back of your cheque.")
          .colspan(3)
          .font(ITextFont.arial_normal_white_8)
          .bgColor(totleChequeAmountBGColor)
          .indent(4F)
          .o();
      addCol(paymentSlipTable, " ").colspan(3).bgColor(totleChequeAmountBGColor).o();
      addCol(paymentSlipTable, "Please post it with this payment slip to")
          .colspan(3)
          .font(ITextFont.arial_normal_white_8)
          .bgColor(totleChequeAmountBGColor)
          .indent(4F)
          .o();
      addCol(
              paymentSlipTable,
              this.getCompanyDetail().getName()
                  + "   "
                  + this.getCompanyDetail().getBilling_address())
          .colspan(3)
          .font(ITextFont.arial_normal_white_8)
          .bgColor(totleChequeAmountBGColor)
          .indent(4F)
          .o();
      addCol(paymentSlipTable, "** PLEASE DO NOT SEND CASH")
          .colspan(2)
          .font(ITextFont.arial_normal_white_8)
          .bgColor(totleChequeAmountBGColor)
          .indent(40F)
          .o();
      addEmptyCol(paymentSlipTable, 2F, 5);
      // complete the table
      paymentSlipTable.completeRow();
      // write the table to an absolute position
      PdfContentByte paymentSlipTableCanvas = writer.getDirectContent();
      paymentSlipTable.writeSelectedRows(
          0,
          -1,
          (PageSize.A4.getWidth() - paymentSlipTable.getTotalWidth()) / 2,
          paymentSlipTable.getTotalHeight() + 28,
          paymentSlipTableCanvas);
      /*
       * PAYMENT SLIP TABLE END
       */
    }

    // FIRST PAGE'S HEADER
    pageHeader(writer);
    /*
     *
     *  FIRST PAGE END
     *
     */

    // CLOSE DOCUMENT
    document.close();
    return outputFile;
  }