예제 #1
0
 public PdfPCell getPdfPCellAligned(String chunk, int font, int val) {
   PdfPCell pdfPCell =
       new PdfPCell(new Phrase(chunk, FontFactory.getFont(FontFactory.TIMES_ROMAN, 16, font)));
   pdfPCell.setBorder(pdfPCell.NO_BORDER);
   pdfPCell.setPaddingLeft(val);
   return pdfPCell;
 }
예제 #2
0
  private void addCellToTable(PdfPTable table, String content, BaseColor color, boolean header) {

    Phrase phrase = new Phrase(content);
    PdfPCell cell = new PdfPCell(phrase);
    cell.setBorderWidth(1.5F);
    cell.setBackgroundColor(color);

    if (header) {
      phrase.setFont(FontFactory.getFont(FontFactory.HELVETICA_BOLD, 7));
      cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    } else {
      phrase.setFont(FontFactory.getFont(FontFactory.HELVETICA, 7));
      cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    }
    table.addCell(cell);
  }
예제 #3
0
 /**
  * metodo che stampa il titolo di un campionato
  *
  * @param champ campionato
  * @param doc documento su cui stampare
  * @throws DocumentException
  */
 private void printChampTitle(ChampionshipEntity champ, Document doc) throws DocumentException {
   doc.add(
       new Phrase(
           new Chunk(
               "\nCampionato " + champ.getName(),
               FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLD))));
 }
예제 #4
0
 public Font getDefaultFont() {
   Font font =
       FontFactory.getFont(
           getFontFilePath("org/kuali/ole/deliver/batch/fonts/ARIALUNI.TTF"),
           BaseFont.IDENTITY_H,
           10);
   return font;
 }
예제 #5
0
  public void print(String filename) throws IOException, DocumentException {
    EventTree tree = app.getTimelines().getCurrentTree();
    if (tree == null || tree.isEmpty()) return;

    ComplexEvent parent = tree.getTopSelectionParent();
    if (parent == null) return;

    // Instantiation of document object
    Document document = new Document(PageSize.A4, 50, 50, 50, 50);

    // Creation of PdfWriter object
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename));
    document.open();

    // Creation of table
    Paragraph title =
        new Paragraph(
            "A sample output from Zeitline:",
            FontFactory.getFont(FontFactory.TIMES_BOLD, 14, BaseColor.BLUE));
    title.setSpacingAfter(20);
    document.add(title);

    // Setting width rations
    PdfPTable table = new PdfPTable(3);
    float[] tableWidth = {(float) 0.2, (float) 0.12, (float) 0.68};
    table.setWidths(tableWidth);

    // Setting the header
    java.util.List<PdfPCell> headerCells =
        asList(getHeaderCell("Date"), getHeaderCell("MACB"), getHeaderCell("Short Description"));

    for (PdfPCell cell : headerCells) table.addCell(cell);

    // Setting the body
    int max = parent.countChildren();
    for (int i = 0; i < max; i++) {
      AbstractTimeEvent entry = parent.getEventByIndex(i);
      table.addCell(getBodyCell(entry.getStartTime().toString()));

      String name = entry.getName();
      if (name != null && name.length() > 5) {
        String macb = name.substring(0, 4);
        String desc = name.substring(5);

        table.addCell(getBodyCell(macb));
        table.addCell(getBodyCell(desc));
      } else {
        table.addCell("");
        table.addCell("");
      }
    }
    document.add(table);

    // Closure
    document.close();
    writer.close();
  }
예제 #6
0
 private PdfPCell getHeaderCell(String name) {
   PdfPCell cell =
       new PdfPCell(
           new Phrase(name, FontFactory.getFont(FontFactory.TIMES_BOLD, 10, BaseColor.BLACK)));
   cell.setBorderColor(BaseColor.GRAY);
   cell.setBorderWidth(1);
   cell.setPadding(5);
   return cell;
 }
  // --- CREATE TITLE ----------------------------------------------------------------------------
  protected PdfPCell createTitle(String msg, int colspan) {
    cell =
        new PdfPCell(
            new Paragraph(msg, FontFactory.getFont(FontFactory.HELVETICA, 10, Font.UNDERLINE)));
    cell.setColspan(colspan);
    cell.setBorder(PdfPCell.NO_BORDER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);

    return cell;
  }
  // --- CREATE TITLE ----------------------------------------------------------------------------
  protected PdfPCell createLabel(String msg, int fontsize, int colspan, int style) {
    cell =
        new PdfPCell(
            new Paragraph(msg, FontFactory.getFont(FontFactory.HELVETICA, fontsize, style)));
    cell.setColspan(colspan);
    cell.setBorder(PdfPCell.NO_BORDER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);

    return cell;
  }
  // --- CREATE BORDERLESS CELL ------------------------------------------------------------------
  protected PdfPCell createBorderlessCell(String value, int height, int colspan) {
    cell =
        new PdfPCell(
            new Paragraph(value, FontFactory.getFont(FontFactory.HELVETICA, 7, Font.NORMAL)));
    cell.setPaddingTop(height); //
    cell.setColspan(colspan);
    cell.setBorder(PdfPCell.NO_BORDER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_TOP);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);

    return cell;
  }
  // --- CREATE NUMBER VALUE CELL ----------------------------------------------------------------
  protected PdfPCell createNumberCell(String value, int colspan) {
    cell =
        new PdfPCell(
            new Paragraph(value, FontFactory.getFont(FontFactory.HELVETICA, 7, Font.NORMAL)));
    cell.setColspan(colspan);
    cell.setBorder(PdfPCell.BOX);
    cell.setBorderColor(innerBorderColor);
    cell.setVerticalAlignment(PdfPCell.ALIGN_TOP);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);

    return cell;
  }
  // --- CREATE UNDERLINED CELL ------------------------------------------------------------------
  protected PdfPCell createUnderlinedCell(String value, int colspan) {
    cell =
        new PdfPCell(
            new Paragraph(
                value,
                FontFactory.getFont(FontFactory.HELVETICA, 7, Font.UNDERLINE))); // underlined
    cell.setColspan(colspan);
    cell.setBorder(PdfPCell.NO_BORDER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_TOP);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);

    return cell;
  }
  // --- CREATE PADDED VALUE CELL ----------------------------------------------------------------
  protected PdfPCell createPaddedValueCell(String value, int colspan) {
    cell =
        new PdfPCell(
            new Paragraph(value, FontFactory.getFont(FontFactory.HELVETICA, 7, Font.NORMAL)));
    cell.setColspan(colspan);
    cell.setBorder(PdfPCell.BOX);
    cell.setBorderColor(innerBorderColor);
    cell.setVerticalAlignment(PdfPCell.ALIGN_TOP);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
    cell.setPaddingRight(5); // difference

    return cell;
  }
  // --- CREATE ITEMNAME CELL --------------------------------------------------------------------
  protected PdfPCell createItemNameCell(String itemName, int colspan) {
    cell =
        new PdfPCell(
            new Paragraph(
                itemName,
                FontFactory.getFont(FontFactory.HELVETICA, 7, Font.NORMAL))); // no uppercase
    cell.setColspan(colspan);
    cell.setBorder(PdfPCell.BOX);
    cell.setBorderColor(innerBorderColor);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);

    return cell;
  }
예제 #14
0
 public void populateFontMap() {
   fontMap.put("COURIER", new Font(FontFactory.getFont("Times-Roman", Font.BOLD).getBaseFont()));
   fontMap.put(
       "COURIER", new Font(FontFactory.getFont("Times-Roman", Font.BOLDITALIC).getBaseFont()));
   fontMap.put(
       "COURIER", new Font(FontFactory.getFont("Times-Roman", Font.DEFAULTSIZE).getBaseFont()));
   fontMap.put(
       "COURIER", new Font(FontFactory.getFont("Times-Roman", Font.STRIKETHRU).getBaseFont()));
   fontMap.put("COURIER", new Font(FontFactory.getFont("Times-Roman", Font.NORMAL).getBaseFont()));
   fontMap.put(
       "COURIER", new Font(FontFactory.getFont("Times-Roman", Font.UNDEFINED).getBaseFont()));
   fontMap.put(
       "COURIER", new Font(FontFactory.getFont("Times-Roman", Font.UNDERLINE).getBaseFont()));
 }
예제 #15
0
 public Font getFont(String data) {
   String myData = new String(data);
   List<Character.UnicodeBlock> unicodeBlocks = new ArrayList<>();
   if (StringUtils.isNotBlank(myData)) {
     unicodeBlocks = getListOfLanguage(myData);
   }
   if (unicodeBlocks.contains(Character.UnicodeBlock.ARABIC)) {
     Font font =
         FontFactory.getFont(
             getFontFilePath("org/kuali/ole/deliver/batch/fonts/arial.ttf"),
             BaseFont.IDENTITY_H,
             BaseFont.EMBEDDED);
     return font;
   } else {
     return getDefaultFont();
   }
 }
예제 #16
0
 public static void main(String[] args) {
   Document document = new Document(); // 创建文档对象
   try {
     PdfWriter.getInstance(document, new FileOutputStream("C:\\明日科技简介.pdf")); // 关联文档对象与输出流
     document.open(); // 打开文档
     document.add(new Paragraph("Generalize")); // 向文档中添加内容
     document.add(
         new Paragraph(
             "Welcome to GuangZhou!",
             FontFactory.getFont(FontFactory.HELVETICA, 15, Font.UNDERLINE))); // 向文档中添加内容
     document.close(); // 关闭文档
   } catch (FileNotFoundException e) {
     e.printStackTrace();
   } catch (DocumentException e) {
     e.printStackTrace();
   }
 }
예제 #17
0
  /**
   * metodo che stampa la classifica su pdf
   *
   * @param ranks lista di coppie (squadra, punteggio)
   * @param isConcluse flag vero se la classifica � definitiva
   * @param doc documento pdf su cui stampare
   * @throws DocumentException sollevata quando si verificano errori di stampa su pdf
   */
  private void printRanking(List<Pair<TeamEntity, Integer>> ranks, Boolean isConcluse, Document doc)
      throws DocumentException {
    // tabella pdf, 3 colonne
    PdfPTable table = new PdfPTable(3);
    // cella
    PdfPCell cell;
    // aggiungi le celle di intestazione
    table.setHeaderRows(1);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.setWidthPercentage(100);
    table.setWidths(new float[] {0.2f, 1, 0.2f});
    table.addCell("Posizione");
    table.addCell("Squadra");
    table.addCell("Punteggio");

    Integer position = 0;
    Integer oldPoints = Integer.MAX_VALUE;
    Integer newPoints;
    for (Iterator<Pair<TeamEntity, Integer>> it = ranks.iterator(); it.hasNext(); ) {
      Pair<TeamEntity, Integer> coppia = it.next();
      newPoints = coppia.getSecond();
      // se non � un parimerito avanza di posizione
      if (newPoints < oldPoints) {
        oldPoints = newPoints;
        position++;
      }
      // stampa la posizione
      table.addCell(position.toString());
      // stampa il nome della squadra
      cell = new PdfPCell(new Phrase(coppia.getFirst().getName()));
      cell.setHorizontalAlignment(Element.ALIGN_LEFT);
      table.addCell(cell);
      // stampa il punteggio
      table.addCell(newPoints.toString());
    }

    // aggiungi il titolo al pdf
    doc.add(
        new Phrase(
            new Chunk(
                "\nClassifica " + (isConcluse ? "definitiva" : "provvisoria"),
                FontFactory.getFont(FontFactory.HELVETICA, 16, Font.BOLD))));
    // aggiungi la tabella al pdf
    doc.add(table);
  }
예제 #18
0
  @Override
  protected void buildPdfDocument(
      Map<String, Object> model,
      Document doc,
      PdfWriter writer,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    // get data model which is passed by the Spring container
    Test test = (Test) model.get("test");

    doc.add(new Paragraph(test.getName()));
    doc.add(new Paragraph(test.getMaterial().getName()));

    Set<TestAttribute> sta = test.getTestAttributs();
    if (sta.size() > 0) {
      PdfPTable table = new PdfPTable(2);
      table.setWidthPercentage(100.0f);
      table.setWidths(new float[] {1.0f});
      table.setSpacingBefore(10);

      // define font for table header row
      Font font = FontFactory.getFont(FontFactory.HELVETICA);
      font.setColor(BaseColor.WHITE);

      // define table header cell
      PdfPCell cell = new PdfPCell();
      cell.setBackgroundColor(BaseColor.BLUE);
      cell.setPadding(5);

      // write table header
      cell.setPhrase(new Phrase("Test attribute type", font));
      table.addCell(cell);
      cell.setPhrase(new Phrase("Value", font));
      table.addCell(cell);

      for (TestAttribute ta : sta) {
        table.addCell(ta.getTypeTestAttr().getName());
        table.addCell(ta.getValue());
      }

      doc.add(table);
    }
  }
예제 #19
0
  public void export(
      HttpServletResponse response, Long id, List<DemandeValidationConsoTempsAccPers> dctap) {

    try {
      Connection con = ds.getConnection();
      Statement select = con.createStatement();
      ResultSet rs = select.executeQuery("SELECT user.* FROM user where id = " + id);
      Document document = new Document(PageSize.A4);

      try {
        OutputStream out = response.getOutputStream();
        PdfWriter writer = PdfWriter.getInstance(document, out);
        writer.setViewerPreferences(PdfWriter.PageLayoutSinglePage | PdfWriter.PageModeUseThumbs);

        document.open();

        rs.last();
        String eleve = "Nom : " + rs.getString("nom");
        eleve += "\nPrénom : " + rs.getString("prenom");
        int idClasse = rs.getInt("idClasse");
        rs.beforeFirst();
        ResultSet rs2 = select.executeQuery("SELECT classe.* from classe where id = " + idClasse);
        rs2.last();
        eleve += "\nClasse : " + rs2.getString("libelle") + "\n\n\n";
        rs2.beforeFirst();

        Paragraph paragraph = new Paragraph(eleve);
        paragraph.setAlignment(Element.ALIGN_LEFT);
        document.add(paragraph);

        com.itextpdf.text.Font fontbold = FontFactory.getFont("Times-Roman", 18, Font.BOLD);
        paragraph = new Paragraph("Les demandes de validations\n\n", fontbold);
        paragraph.setAlignment(Element.ALIGN_CENTER);
        document.add(paragraph);

        int timeTT = 0, timeVal = 0, timeAtt = 0, timeRef = 0;
        for (int i = 0; i < dctap.size(); i++) {
          timeTT += dctap.get(i).getMinutes();
          if (dctap.get(i).getEtat() == 1 || dctap.get(i).getEtat() == 32) {
            timeVal += dctap.get(i).getMinutes();
          } else if (dctap.get(i).getEtat() == 2
              || dctap.get(i).getEtat() == 8
              || dctap.get(i).getEtat() == 64) {
            timeRef += dctap.get(i).getMinutes();
          } else if (dctap.get(i).getEtat() == 0
              || dctap.get(i).getEtat() == 4
              || dctap.get(i).getEtat() > 1023) {
            timeAtt += dctap.get(i).getMinutes();
          }
        }
        double timeTTpercent = timeVal,
            timeValPercent = timeVal,
            timeAttPercent = timeAtt,
            timeRefPercent = timeRef;
        timeTTpercent =
            Math.round((timeTTpercent / (72 * 60) * 100) * Math.pow(10.0, 2)) / Math.pow(10.0, 2);
        timeValPercent =
            Math.round(((timeValPercent / timeTT) * 100) * Math.pow(10.0, 2)) / Math.pow(10.0, 2);
        timeAttPercent =
            Math.round(((timeAttPercent / timeTT) * 100) * Math.pow(10.0, 2)) / Math.pow(10.0, 2);
        timeRefPercent =
            Math.round(((timeRefPercent / timeTT) * 100) * Math.pow(10.0, 2)) / Math.pow(10.0, 2);

        PdfPTable table = new PdfPTable(4);

        PdfPCell c1 =
            new PdfPCell(
                new Phrase(
                    "Temps total effectué (72h)",
                    FontFactory.getFont(FontFactory.TIMES_ROMAN, 15, com.itextpdf.text.Font.BOLD)));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        c1.setPaddingBottom(7);
        table.addCell(c1);
        c1 =
            new PdfPCell(
                new Phrase(
                    "Temps total validé",
                    FontFactory.getFont(FontFactory.TIMES_ROMAN, 15, com.itextpdf.text.Font.BOLD)));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        c1.setPaddingBottom(7);
        table.addCell(c1);
        c1 =
            new PdfPCell(
                new Phrase(
                    "Temps total en attente",
                    FontFactory.getFont(FontFactory.TIMES_ROMAN, 15, com.itextpdf.text.Font.BOLD)));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        c1.setPaddingBottom(7);
        table.addCell(c1);
        c1 =
            new PdfPCell(
                new Phrase(
                    "Temps total refusé",
                    FontFactory.getFont(FontFactory.TIMES_ROMAN, 15, com.itextpdf.text.Font.BOLD)));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        c1.setPaddingBottom(7);
        table.addCell(c1);

        table.setHeaderRows(1);

        c1 =
            new PdfPCell(
                new Phrase((timeTT / 60 - (timeTT % 60 / 60)) + "h " + (timeTT % 60) + "min"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        c1.setPaddingBottom(4);
        table.addCell(c1);
        c1 =
            new PdfPCell(
                new Phrase((timeVal / 60 - (timeVal % 60 / 60)) + "h " + (timeVal % 60) + "min"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        c1.setPaddingBottom(4);
        table.addCell(c1);
        c1 =
            new PdfPCell(
                new Phrase((timeAtt / 60 - (timeAtt % 60 / 60)) + "h " + (timeAtt % 60) + "min"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        c1.setPaddingBottom(4);
        table.addCell(c1);
        c1 =
            new PdfPCell(
                new Phrase((timeRef / 60 - (timeRef % 60 / 60)) + "h " + (timeRef % 60) + "min"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        c1.setPaddingBottom(4);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase(timeTTpercent + "%"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        c1.setPaddingBottom(4);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase(timeValPercent + "%"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        c1.setPaddingBottom(4);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase(timeAttPercent + "%"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        c1.setPaddingBottom(4);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase(timeRefPercent + "%"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        c1.setPaddingBottom(4);
        table.addCell(c1);

        document.add(table);

      } catch (DocumentException de) {
        de.printStackTrace();
      } catch (IOException ioe) {
        ioe.printStackTrace();
      }
      document.close();

    } catch (SQLException e) {
      e.printStackTrace();
    }
  }
예제 #20
0
  /** @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    Logger logger = GenericUtilities.checkLoggedIn(request, response, false);
    String todo = request.getParameter("todo");
    if (todo != null && todo.equals("printPDF")) {
      // --- stampa PDF ---
      Document doc = new Document();
      File file = new File("filePDF_" + logger.getUser().getId() + ".pdf");
      FileOutputStream os = new FileOutputStream(file);
      String str = file.getAbsolutePath();
      Boolean printTeams = request.getParameter("hire") != null;
      Boolean printMatches = request.getParameter("match") != null;
      Boolean printChampResults = request.getParameter("champ") != null;
      try {

        // campionati a cui l'utente partecipa
        List<ChampionshipEntity> cl =
            MySQLConnection.getChampionshipOfUser(logger.getUser().getId());
        // apri il documento PDF
        PdfWriter.getInstance(doc, os);
        doc.open();
        doc.add(
            new Phrase(
                new Chunk(
                    "Fantaservlet: utente " + logger.getUser().getName(),
                    FontFactory.getFont(FontFactory.HELVETICA, 20, Font.BOLD))));
        // per ogni campionato
        for (Iterator<ChampionshipEntity> it = cl.iterator(); it.hasNext(); ) {
          ChampionshipEntity champ = it.next();
          printChampTitle(champ, doc);

          // --- stampa le rose di calciatori ---
          if (printTeams) {
            // prendi la lista delle squadre
            List<TeamEntity> teams = MySQLConnection.getTeamsOfChampionship(champ.getId());
            for (Iterator<TeamEntity> it2 = teams.iterator(); it2.hasNext(); ) {
              TeamEntity team = it2.next();
              printHiring(
                  GenericUtilities.getPlayersListByRule(
                      MySQLConnection.getHiring(team.getId()), 'D'),
                  GenericUtilities.getPlayersListByRule(
                      MySQLConnection.getHiring(team.getId()), 'C'),
                  GenericUtilities.getPlayersListByRule(
                      MySQLConnection.getHiring(team.getId()), 'A'),
                  GenericUtilities.getPlayersListByRule(
                      MySQLConnection.getHiring(team.getId()), 'P'),
                  team,
                  doc);
            }
          }

          if (printMatches || printChampResults) {
            // prendi la lista degli scontri
            List<Match> lm = GenericUtilities.getListOfMatches(champ.getId());
            if (lm.size() > 0) {
              // --- stampa le partite del campionato ---
              if (printMatches) {
                printMatches(lm, GenericUtilities.getNumOfTeams(lm), doc);
              }
              // --- stampa la classifica ---
              if (printChampResults) {
                printRanking(GenericUtilities.getRanking(lm), GenericUtilities.isConcluse(lm), doc);
              }
            }
          }
        }
      } catch (DocumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (SQLException sqle) {
        // TODO errore SQL

      } finally {
        // chiudi documento PDF
        doc.close();
      }
      // stampa il pdf
      doDownload(request, response, str, "filepdf");
    } else {
      // --- stamp pagina e form ---
      response.setContentType("text/html");
      PrintWriter out = response.getWriter();
      out.println(Style.pageHeader(TITLE));

      out.println("<form action=\"PrintPDF\" method=\"POST\">");
      out.println("<input type=\"checkbox\"/ name=\"hire\" checked>Dati squadre<br/>");
      out.println("<input type=\"checkbox\" name=\"match\"/ checked>Risultati partite<br/>");
      out.println(
          "<input type=\"checkbox\" name=\"champ\"/ checked>Classifiche dei campionati<br/><br/>");
      out.println(Style.hidden("todo", "printPDF"));
      out.println("<input type=\"submit\"/>");
      out.println("</form>");
      out.println(Style.pageFooter());
    }
  }
예제 #21
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();
    }
  }
예제 #22
0
 private void printHiring(
     List<PlayerEntity> def,
     List<PlayerEntity> cen,
     List<PlayerEntity> att,
     List<PlayerEntity> golkeep,
     TeamEntity team,
     Document doc)
     throws DocumentException {
   // lista
   com.itextpdf.text.List list;
   // elemento della lista
   ListItem item;
   // calciatore
   PlayerEntity player;
   // stampa nome squadra
   doc.add(
       new Phrase(
           new Chunk(
               "\nSquadra " + team.getName(),
               FontFactory.getFont(FontFactory.HELVETICA, 16, Font.BOLD))));
   // aggiungi i difensori
   doc.add(
       new Phrase(
           new Chunk("\nDifensori", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD))));
   list = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED);
   for (Iterator<PlayerEntity> it = def.iterator(); it.hasNext(); ) {
     player = it.next();
     item = new ListItem(player.getName() + " - " + player.getTeam());
     list.add(item);
   }
   doc.add(list);
   // aggiungi i centrocampisti
   doc.add(
       new Phrase(
           new Chunk(
               "Centrocampisti", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD))));
   list = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED);
   for (Iterator<PlayerEntity> it = cen.iterator(); it.hasNext(); ) {
     player = it.next();
     item = new ListItem(player.getName() + " - " + player.getTeam());
     list.add(item);
   }
   doc.add(list);
   // aggiungi gli attaccanti
   doc.add(
       new Phrase(
           new Chunk("Attaccanti", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD))));
   list = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED);
   for (Iterator<PlayerEntity> it = att.iterator(); it.hasNext(); ) {
     player = it.next();
     item = new ListItem(player.getName() + " - " + player.getTeam());
     list.add(item);
   }
   doc.add(list);
   // aggiungi i portieri
   doc.add(
       new Phrase(
           new Chunk("Portieri", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD))));
   list = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED);
   for (Iterator<PlayerEntity> it = golkeep.iterator(); it.hasNext(); ) {
     player = it.next();
     item = new ListItem(player.getName() + " - " + player.getTeam());
     list.add(item);
   }
   doc.add(list);
 }
예제 #23
0
 public Font getBoldFont() {
   Font boldFont = FontFactory.getFont("Times-Roman", 15, Font.BOLD);
   return boldFont;
 }
예제 #24
0
    @Override
    public void onEndPage(PdfWriter writer, Document document) {
      Rectangle rect = writer.getBoxSize("art");

      Image imghead = null;
      PdfContentByte cbhead = null;

      try {
        imghead = Image.getInstance("LogoSapito5.png");
        imghead.setAbsolutePosition(0, 0);
        imghead.setAlignment(Image.ALIGN_CENTER);
        imghead.scalePercent(10f);
        cbhead = writer.getDirectContent();
        PdfTemplate tp = cbhead.createTemplate(100, 150);
        tp.addImage(imghead);
        cbhead.addTemplate(tp, 100, 715);

      } catch (BadElementException e) {
        e.printStackTrace();
      } catch (DocumentException e) {
        e.printStackTrace();
      } catch (IOException ex) {
        Logger.getLogger(Cuentaspagar.class.getName()).log(Level.SEVERE, null, ex);
      }

      Phrase headPhraseImg =
          new Phrase(cbhead + "", FontFactory.getFont(FontFactory.TIMES_ROMAN, 7, Font.NORMAL));

      Calendar c1 = Calendar.getInstance();
      Calendar c2 = new GregorianCalendar();
      String dia, mes, annio;
      dia = Integer.toString(c1.get(Calendar.DATE));
      mes = Integer.toString(c1.get(Calendar.MONTH));
      annio = Integer.toString(c1.get(Calendar.YEAR));
      java.util.Date fecha = new Date();
      String fechis = dia + "/" + mes + "/" + annio;
      Paragraph parrafo5 =
          new Paragraph(
              fechis,
              FontFactory.getFont(FontFactory.TIMES_ROMAN, 11, Font.NORMAL, BaseColor.BLACK));
      ColumnText.showTextAligned(
          writer.getDirectContent(),
          Element.ALIGN_CENTER,
          new Phrase(parrafo5),
          rect.getRight(450),
          rect.getTop(-80),
          0);

      Paragraph parrafo7 =
          new Paragraph(
              "Empresa Sapito S.A. de C.V.",
              FontFactory.getFont(FontFactory.TIMES_ROMAN, 16, Font.BOLD, BaseColor.BLACK));
      ColumnText.showTextAligned(
          writer.getDirectContent(),
          Element.ALIGN_CENTER,
          new Phrase(parrafo7),
          rect.getBottom(250),
          rect.getTop(-60),
          0);

      Paragraph parrafo8 =
          new Paragraph(
              "Cuentas por cobrar",
              FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.BOLD, BaseColor.BLACK));
      ColumnText.showTextAligned(
          writer.getDirectContent(),
          Element.ALIGN_CENTER,
          new Phrase(parrafo8),
          rect.getBottom(250),
          rect.getTop(-40),
          0);

      ColumnText.showTextAligned(
          writer.getDirectContent(),
          Element.ALIGN_BOTTOM,
          new Phrase(
              "      _________________________________________________________________________________    "),
          rect.getBorder(),
          rect.getTop(-24),
          0);

      ColumnText.showTextAligned(
          writer.getDirectContent(),
          Element.ALIGN_BOTTOM,
          new Phrase(
              "      _________________________________________________________________________________    "),
          rect.getBorder(),
          rect.getTop(-20),
          0);

      Paragraph parrafo6 =
          new Paragraph(
              String.format("Pág %d", writer.getPageNumber()),
              FontFactory.getFont(FontFactory.TIMES_ROMAN, 11, Font.NORMAL, BaseColor.BLACK));
      ColumnText.showTextAligned(
          writer.getDirectContent(),
          Element.ALIGN_CENTER,
          new Phrase(parrafo6),
          rect.getRight(-35),
          rect.getTop(-80),
          0);
    }
예제 #25
0
  /**
   * metodo di stampa dei risultati delle partite di un campionato su pdf
   *
   * @param matches lista delle partite del campionato
   * @param numTeams numero delle squadre che vi partecipano
   * @param doc documento pdf su cui stampare
   * @throws DocumentException sollevata quando si verificano errori di stampa su pdf
   */
  private void printMatches(List<Match> matches, Integer numTeams, Document doc)
      throws DocumentException {
    // numero delle partite
    Integer matchPerDay = numTeams / 2;
    // tabella pdf
    PdfPTable table = new PdfPTable(7);
    // cella pdf
    PdfPCell cell;
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.setWidthPercentage(100);
    table.setWidths(new float[] {1, 2, 2, 0.5f, 0.5f, 0.5f, 0.5f});
    // stampa i titoli della tabella
    cell = new PdfPCell(new Phrase("Giornata"));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(cell);
    cell.setPhrase(new Phrase("Partita"));
    cell.setColspan(2);
    table.addCell(cell);
    cell.setPhrase(new Phrase("Risultato"));
    table.addCell(cell);
    cell.setPhrase(new Phrase("Punti"));
    table.addCell(cell);

    Integer counter = 0;
    // per ogni partita
    for (Iterator<Match> it = matches.iterator();
        it.hasNext();
        counter = (counter + 1) % matchPerDay) {
      Match match = it.next();
      if (counter == 0) {
        // inserisci la data della giornata
        cell = new PdfPCell(new Phrase(match.getDay().getFormatDate()));
        cell.setRowspan(matchPerDay);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);

        table.addCell(cell);
      }
      // stampa i nomi delle squadre
      table.addCell(match.getTeam1().getName());
      table.addCell(match.getTeam2().getName());

      // stampa i gol segnati
      if (match.getDay().isEvaluated()) {
        table.addCell(GenericUtilities.pointsToGol(match.getPointsTeam1()).toString());
        table.addCell(GenericUtilities.pointsToGol(match.getPointsTeam2()).toString());
        table.addCell(match.getPointsTeam1().toString());
        table.addCell(match.getPointsTeam2().toString());
      } else {
        table.addCell("NA");
        table.addCell("NA");
        table.addCell("NA");
        table.addCell("NA");
      }
    }

    // inserisci il titolo nel documento
    doc.add(
        new Phrase(
            new Chunk(
                "\nRisultati delle partite",
                FontFactory.getFont(FontFactory.HELVETICA, 16, Font.BOLD))));
    // inserisci la tabella nel documento
    doc.add(table);
  }
예제 #26
0
    @Override
    public BaseFont getBaseFont(java.awt.Font font) {
      try {
        if (font != null) {
          BaseFont baseFont = null;
          if (!font.getFontName().equals(FontFactory.COURIER)
              && !font.getFontName().equals(FontFactory.COURIER_BOLD)
              && !font.getFontName().equals(FontFactory.COURIER_OBLIQUE)
              && !font.getFontName().equals(FontFactory.COURIER_BOLDOBLIQUE)
              && !font.getFontName().equals(FontFactory.HELVETICA)
              && !font.getFontName().equals(FontFactory.HELVETICA_BOLD)
              && !font.getFontName().equals(FontFactory.HELVETICA_BOLDOBLIQUE)
              && !font.getFontName().equals(FontFactory.HELVETICA_OBLIQUE)
              && !font.getFontName().equals(FontFactory.SYMBOL)
              && !font.getFontName().equals(FontFactory.TIMES_ROMAN)
              && !font.getFontName().equals(FontFactory.TIMES_BOLD)
              && !font.getFontName().equals(FontFactory.TIMES_ITALIC)
              && !font.getFontName().equals(FontFactory.TIMES_BOLDITALIC)
              && !font.getFontName().equals(FontFactory.ZAPFDINGBATS)
              && !font.getFontName().equals(FontFactory.COURIER_BOLD)
              && !font.getFontName().equals(FontFactory.COURIER_BOLD)
              && !font.getFontName().equals(FontFactory.COURIER_BOLD)) {

            com.itextpdf.text.Font itextFont =
                FontFactory.getFont(
                    font.getFontName(), BaseFont.IDENTITY_H, font.getSize(), font.getStyle());
            baseFont = itextFont.getBaseFont();
            if (baseFont == null && !PDFRenderTargetImpl.fontRegistered) {

              if (progressTicket != null) {
                String displayName = progressTicket.getDisplayName();
                Progress.setDisplayName(
                    progressTicket,
                    NbBundle.getMessage(
                        PDFRenderTargetImpl.class, "PDFRenderTargetImpl.font.registration"));
                registerFonts();
                Progress.setDisplayName(progressTicket, displayName);
              }

              itextFont =
                  FontFactory.getFont(
                      font.getFontName(), BaseFont.IDENTITY_H, font.getSize(), font.getStyle());
              baseFont = itextFont.getBaseFont();

              PDFRenderTargetImpl.fontRegistered = true;
            }
          } else {
            com.itextpdf.text.Font itextFont =
                FontFactory.getFont(
                    font.getFontName(), BaseFont.IDENTITY_H, font.getSize(), font.getStyle());
            baseFont = itextFont.getBaseFont();
          }

          if (baseFont != null) {
            return baseFont;
          }
          return BaseFont.createFont();
        }
        return BaseFont.createFont();
      } catch (Exception e) {
        Exceptions.printStackTrace(e);
      }
      return null;
    }
  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;
  }
예제 #28
0
 private Phrase getBodyCell(String name) {
   return new Phrase(name, FontFactory.getFont(FontFactory.TIMES, 8, BaseColor.BLACK));
 }