xx
孔祥富
2021-03-09 18f8df401b74deec5c1ef552b2b1c7fa89cd9cb6
febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/util/CreatePdf.java
@@ -78,7 +78,7 @@
      }
   }
   int maxWidth = 842;
   int maxWidth = 800;
   /**
    * 为表格添加一个内容
@@ -138,39 +138,7 @@
      return cell;
   }
   /**
    * 为表格添加一个内容
    *
    * @param value
    *            值
    * @param font
    *            字体
    * @param align
    *            对齐方式
    * @param colspan
    *            占多少列
    * @param boderFlag
    *            是否有有边框
    * @return 添加的文本框
    */
   public PdfPCell createCell(String value, Font font, int align, int colspan, boolean boderFlag) {
      PdfPCell cell = new PdfPCell();
      cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
      cell.setHorizontalAlignment(align);
      cell.setColspan(colspan);
      cell.setPhrase(new Phrase(value, font));
      cell.setPadding(3.0f);
      if (!boderFlag) {
         cell.setBorderColorBottom(BaseColor.GRAY);
         cell.setBorderColorLeft(BaseColor.GRAY);
         cell.setBorderColorRight(BaseColor.GRAY);
         cell.setBorderColorTop(BaseColor.GRAY);
         cell.setBorder(0);
         cell.setPaddingTop(15.0f);
         cell.setPaddingBottom(8.0f);
      }
      return cell;
   }
   /**
    * 创建一个表格对象
@@ -219,6 +187,40 @@
      Font fontChinese = new Font(bfChinese, 12, Font.NORMAL);
      return fontChinese;
   }
   /**
    * 为表格添加一个内容
    *
    * @param value
    *            值
    * @param font
    *            字体
    * @param align
    *            对齐方式
    * @param colspan
    *            占多少列
    * @param boderFlag
    *            是否有有边框
    * @return 添加的文本框
    */
   public PdfPCell createCell(String value, Font font, int align, int colspan, boolean boderFlag) {
      PdfPCell cell = new PdfPCell();
      cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
      cell.setHorizontalAlignment(align);
      cell.setColspan(colspan);
      cell.setPhrase(new Phrase(value, font));
      cell.setPadding(3.0f);
      cell.setMinimumHeight(30);
      cell.setBorderColorBottom(BaseColor.BLACK);
      cell.setBorderColorLeft(BaseColor.BLACK);
      cell.setBorderColorRight(BaseColor.BLACK);
      cell.setBorderColorTop(BaseColor.BLACK);
      if (!boderFlag) {
         cell.setBorder(0);
         cell.setPaddingTop(15.0f);
         cell.setPaddingBottom(8.0f);
      }
      return cell;
   }
   public static void setTableStyle(PdfPTable table, PdfPCell cell) {
// 设置表格样式
      table.setLockedWidth(true);
@@ -234,10 +236,10 @@
      cell.setBorderWidthBottom(0.1f);
      cell.setBorderWidthLeft(0.1f);
      cell.setBorderWidthRight(0.1f);
      cell.setBorderColorBottom(BaseColor.GRAY);
      cell.setBorderColorLeft(BaseColor.GRAY);
      cell.setBorderColorRight(BaseColor.GRAY);
      cell.setBorderColorTop(BaseColor.GRAY);
      cell.setBorderColorBottom(BaseColor.BLACK);
      cell.setBorderColorLeft(BaseColor.BLACK);
      cell.setBorderColorRight(BaseColor.BLACK);
      cell.setBorderColorTop(BaseColor.BLACK);
      cell.setPadding(3);
   }
   /**
@@ -351,7 +353,7 @@
                  "现住址",empBaseInfo.getCurrentAddress()==null?"":empBaseInfo.getCurrentAddress(),
                  "保安员回执",empBaseInfo.getReturnReceipt()==null?"":empBaseInfo.getReturnReceipt()},
            {"保安员证号",empBaseInfo.getGuardNumb()==null?"":empBaseInfo.getGuardNumb(),
                  "档案情况",empBaseInfo.getArchivesStatus()==null?"":empBaseInfo.getArchivesStatus(),
                  "档案情况",empBaseInfo.getArchivesStatusName()==null?"":empBaseInfo.getArchivesStatusName(),
                  "银行名称",empBaseInfo.getBankName()==null?"":empBaseInfo.getBankName()},
            {"银行账号",empBaseInfo.getBankNumb()==null?"":empBaseInfo.getBankNumb(),
                  "电话号码",empBaseInfo.getTelePhone()==null?"":empBaseInfo.getTelePhone(),
@@ -366,6 +368,38 @@
                  "员工手册",empBaseInfo.getHandbookStatusName()==null?"":empBaseInfo.getHandbookStatusName(),
                  "相关证件",empBaseInfo.getCertificateListName()==null?"":empBaseInfo.getCertificateListName()},
            {"身份证号码",empBaseInfo.getCertificateNumb()==null?"":empBaseInfo.getCertificateNumb()}};
      //生成三列表格
      PdfPTable table1 = new PdfPTable(1);
      PdfPCell cell1 = new PdfPCell();
      cell1.setBorderWidthTop(0);
      cell1.setBorderWidthRight(0);
      cell1.setBorderWidthBottom(0);
      cell1.setBorderWidthLeft(0);
      cell1.setUseAscender(true);
      cell1.setUseDescender(true);
      cell1.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);//水平居中
      Paragraph para = null;
      try {
         para = new Paragraph(empBaseInfo.getEmpName()+"的档案", getPdfChineseFont());
      } catch (Exception e) {
         e.printStackTrace();
      }
      //设置该段落为居中显示
      cell1.setPhrase(para);
      table1.addCell(cell1);
//         每个cell的宽度
      float[] widthss = {400, 400, 400, 400,400, 400};
//          创建一个表格,每一行有四个cell
@@ -669,6 +703,7 @@
         }
      }
      try {
         document.add(table1);
         // 将表格添加到文档中
         document.add(basicTable);
         document.add(workheadtable);