一、准备生成的文件

二、分析文件结构

在文件中,

  1. 文件标题下面用双划线标识
  2. 表格外围边框也是双线
  3. 右侧的两个密集的单元格,外围也是双线

三、提出解决方法

  1. 设想使用pdfPTable某些属性或方法,设置边框双线;
    经测试,未找到有效的解决属性和方法;此方法泡汤
  2. 使用单元格内套表格的方式
    经测试,此方法可成

四、具体代码实现

代码量较多,可以粘贴到自己的编译器中进行测试

// 生成记账凭证private String createCertificationPDF(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException, Exception {String planNameP = request.getParameter("planNameP");String ceritNameP = request.getParameter("ceritNameP");Date date = new Date();String startD = new SimpleDateFormat("HH-mm-ss").format(date);String oldPath = makePdfFilePath + pString +  planNameP+"_"+ceritNameP+startD+ ".pdf";try {/*String year = request.getParameter("year");String cycle = request.getParameter("cycle");String startDate = request.getParameter("startDate");String endDate = request.getParameter("endDate");Date startD1 = new SimpleDateFormat("yyyy-MM-dd").parse(startDate);String startD = new SimpleDateFormat("yyyy年MM月dd日").format(startD1);String start = new SimpleDateFormat("yyyy年MM月").format(startD1);Date endD1 = new SimpleDateFormat("yyyy-MM-dd").parse(endDate);String endD = new SimpleDateFormat("yyyy年MM月dd日").format(endD1);*/// 创建文件Document document = new Document();document.setPageSize(PageSize.A4);// 建立一个书写器PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(oldPath));// 打开文件document.open();// 中文字体,解决中文不能显示问题String FontChPath = PropertyUitls.getProperties("config.properties").getProperty("fontSourceSong");BaseFont bfChinese = BaseFont.createFont(FontChPath, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);// 蓝色字体Font blueFont = new Font(bfChinese);blueFont.setColor(BaseColor.BLUE);blueFont.setSize(5);// 小三号Font smallThreeFont = new Font(bfChinese, 15);smallThreeFont.setColor(BaseColor.BLACK);// 五号Font fiveFont = new Font(bfChinese);fiveFont.setColor(BaseColor.BLACK);fiveFont.setSize(10.5f);// 五号Font smallFiveFont = new Font(bfChinese);smallFiveFont.setColor(BaseColor.BLACK);smallFiveFont.setSize(9);// 五号Font smallSixFont = new Font(bfChinese);smallSixFont.setColor(BaseColor.BLACK);smallSixFont.setSize(6.5f);// 小四号 加粗Font greenFont = new Font(bfChinese, 12, Font.BOLD);greenFont.setColor(BaseColor.BLACK);// 小四号Font messFont = new Font(bfChinese, 12);messFont.setColor(BaseColor.BLACK);// 标题加粗 四号Font titleFont = new Font(bfChinese, 14, Font.BOLD);titleFont.setColor(BaseColor.BLACK);// 设计一个4列的表.PdfPTable table = new PdfPTable(4);table.setWidthPercentage(100); // 宽度100%填充table.setSpacingBefore(10f); // 前间距table.setSpacingAfter(10f); // 后间距// 设置列宽float[] columnWidths = { 0.8f, 0.8f, 0.5f,0.5f};table.setWidths(columnWidths);PdfPCell cell;//第一行cell = new PdfPCell(new Phrase("", smallThreeFont));cell.setMinimumHeight(20); // 设置单元格高度cell.setUseAscender(true); // 设置可以居中cell.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中cell.setBorder(0);table.addCell(cell);cell = new PdfPCell(new Phrase("记    账    凭    证", smallThreeFont));cell.setMinimumHeight(20); // 设置单元格高度cell.setUseAscender(true); // 设置可以居中cell.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中cell.setBorderWidthTop(0);cell.setBorderWidthLeft(0);cell.setBorderWidthRight(0);table.addCell(cell);cell = new PdfPCell(new Phrase("本位币:CYN", fiveFont));cell.setMinimumHeight(20); // 设置单元格高度cell.setUseAscender(true); // 设置可以居中cell.setHorizontalAlignment(Cell.ALIGN_RIGHT); // 设置水平居中cell.setVerticalAlignment(Cell.ALIGN_BOTTOM); // 设置垂直居中cell.setBorder(0);cell.setColspan(2);table.addCell(cell);cell = new PdfPCell(new Phrase("", fiveFont));cell.setMinimumHeight(2); // 设置单元格高度cell.setUseAscender(true); // 设置可以居中cell.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中cell.setBorder(0);table.addCell(cell);cell = new PdfPCell(new Phrase("", fiveFont));cell.setMinimumHeight(2); // 设置单元格高度cell.setUseAscender(true); // 设置可以居中cell.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中cell.setBorderWidthTop(0);cell.setBorderWidthLeft(0);cell.setBorderWidthRight(0);table.addCell(cell);cell = new PdfPCell(new Phrase("", fiveFont));cell.setMinimumHeight(2); // 设置单元格高度cell.setUseAscender(true); // 设置可以居中cell.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中cell.setBorder(0);cell.setColspan(2);table.addCell(cell);//第二行cell = new PdfPCell(new Phrase("", fiveFont));cell.setMinimumHeight(20); // 设置单元格高度cell.setUseAscender(true); // 设置可以居中cell.setHorizontalAlignment(Cell.ALIGN_LEFT); // 设置水平居中cell.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中cell.setBorder(0);table.addCell(cell);cell = new PdfPCell(new Phrase("XXX公司职业年金计划", fiveFont));cell.setMinimumHeight(20); // 设置单元格高度cell.setUseAscender(true); // 设置可以居中cell.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中cell.setBorder(0);table.addCell(cell);cell = new PdfPCell(new Phrase("附单据数:0张", fiveFont));cell.setMinimumHeight(20); // 设置单元格高度cell.setUseAscender(true); // 设置可以居中cell.setHorizontalAlignment(Cell.ALIGN_RIGHT); // 设置水平居中cell.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中cell.setColspan(2);cell.setBorder(0);table.addCell(cell);//第三行cell = new PdfPCell(new Phrase("", fiveFont));cell.setMinimumHeight(20); // 设置单元格高度cell.setUseAscender(true); // 设置可以居中cell.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中cell.setBorder(0);table.addCell(cell);cell = new PdfPCell(new Phrase("凭证日期:XXXX年XX月XX日", fiveFont));cell.setMinimumHeight(20); // 设置单元格高度cell.setUseAscender(true); // 设置可以居中cell.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中cell.setBorder(0);table.addCell(cell);cell = new PdfPCell(new Phrase("凭证编号:XXXXX号", fiveFont));cell.setMinimumHeight(20); // 设置单元格高度cell.setUseAscender(true); // 设置可以居中cell.setHorizontalAlignment(Cell.ALIGN_RIGHT); // 设置水平居中cell.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中cell.setBorder(0);cell.setColspan(2);table.addCell(cell);// 设计一个4列的表.PdfPTable table0 = new PdfPTable(2);table0.setWidthPercentage(100); // 宽度100%填充// 设置列宽float[] columnWidths0 = { 0.8f, 0.8f};table0.setWidths(columnWidths0);PdfPCell cell0;//正文第1行cell0 = new PdfPCell(new Phrase("摘要", fiveFont));cell0.setMinimumHeight(28); // 设置单元格高度cell0.setUseAscender(true); // 设置可以居中cell0.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell0.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中cell0.setRowspan(2);table0.addCell(cell0);cell0 = new PdfPCell(new Phrase("科目", fiveFont));cell0.setMinimumHeight(28); // 设置单元格高度cell0.setUseAscender(true); // 设置可以居中cell0.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell0.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中cell0.setRowspan(2);table0.addCell(cell0);cell0 = new PdfPCell(new Phrase("{2018-11-24}税金计提", smallFiveFont));cell0.setMinimumHeight(20); // 设置单元格高度cell0.setUseAscender(true); // 设置可以居中cell0.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell0.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table0.addCell(cell0);cell0 = new PdfPCell(new Phrase("其他应付款-支付与转出", smallFiveFont));cell0.setMinimumHeight(20); // 设置单元格高度cell0.setUseAscender(true); // 设置可以居中cell0.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell0.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table0.addCell(cell0);//2222222222cell0 = new PdfPCell(new Phrase("3", smallFiveFont));cell0.setMinimumHeight(20); // 设置单元格高度cell0.setUseAscender(true); // 设置可以居中cell0.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell0.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table0.addCell(cell0);cell0 = new PdfPCell(new Phrase("3", smallFiveFont));cell0.setMinimumHeight(20); // 设置单元格高度cell0.setUseAscender(true); // 设置可以居中cell0.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell0.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table0.addCell(cell0);cell0 = new PdfPCell(new Phrase("3", smallFiveFont));cell0.setMinimumHeight(20); // 设置单元格高度cell0.setUseAscender(true); // 设置可以居中cell0.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell0.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table0.addCell(cell0);cell0 = new PdfPCell(new Phrase("3", smallFiveFont));cell0.setMinimumHeight(20); // 设置单元格高度cell0.setUseAscender(true); // 设置可以居中cell0.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell0.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table0.addCell(cell0);cell0 = new PdfPCell(new Phrase("3", smallFiveFont));cell0.setMinimumHeight(20); // 设置单元格高度cell0.setUseAscender(true); // 设置可以居中cell0.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell0.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table0.addCell(cell0);cell0 = new PdfPCell(new Phrase("3", smallFiveFont));cell0.setMinimumHeight(20); // 设置单元格高度cell0.setUseAscender(true); // 设置可以居中cell0.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell0.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table0.addCell(cell0);cell0 = new PdfPCell(new Phrase("3", smallFiveFont));cell0.setMinimumHeight(20); // 设置单元格高度cell0.setUseAscender(true); // 设置可以居中cell0.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell0.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table0.addCell(cell0);cell0 = new PdfPCell(new Phrase("3", smallFiveFont));cell0.setMinimumHeight(20); // 设置单元格高度cell0.setUseAscender(true); // 设置可以居中cell0.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell0.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table0.addCell(cell0);cell0 = new PdfPCell(new Phrase("3", smallFiveFont));cell0.setMinimumHeight(20); // 设置单元格高度cell0.setUseAscender(true); // 设置可以居中cell0.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell0.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table0.addCell(cell0);cell0 = new PdfPCell(new Phrase("3", smallFiveFont));cell0.setMinimumHeight(20); // 设置单元格高度cell0.setUseAscender(true); // 设置可以居中cell0.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell0.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table0.addCell(cell0);//左上角cell = new PdfPCell(new Phrase("", fiveFont));cell.setMinimumHeight(150); // 设置单元格高度cell.setUseAscender(true); // 设置可以居中cell.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中
//              cell.enableBorderSide(1);cell.setRowspan(8);cell.setColspan(2);cell.setBorderWidthRight(0);cell.setBorderWidthBottom(0);cell.setPaddingRight(-0.2f);cell.addElement(table0);table.addCell(cell);// 借方发生的  设计一个10列的表.PdfPTable table1 = new PdfPTable(10);table1.setWidthPercentage(102); // 宽度100%填充
//              table1.setSpacingBefore(10f); // 前间距
//              table1.setSpacingAfter(10f); // 后间距// 设置列宽float[] columnWidths1 = { 0.06f,0.06f,0.06f,0.06f,0.06f,0.06f,0.06f,0.06f,0.06f,0.06f};table1.setWidths(columnWidths1);PdfPCell cell1;cell1 = new PdfPCell(new Phrase("借方发生", fiveFont));cell1.setMinimumHeight(13); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_TOP); // 设置垂直居中cell1.setColspan(10);table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("千", smallSixFont));cell1.setMinimumHeight(15); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("百", smallSixFont));cell1.setMinimumHeight(15); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("十", smallSixFont));cell1.setMinimumHeight(15); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("万", smallSixFont));cell1.setMinimumHeight(15); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("千", smallSixFont));cell1.setMinimumHeight(15); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("百", smallSixFont));cell1.setMinimumHeight(15); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("十", smallSixFont));cell1.setMinimumHeight(15); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("元", smallSixFont));cell1.setMinimumHeight(15); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("角", smallSixFont));cell1.setMinimumHeight(15); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("分", smallSixFont));cell1.setMinimumHeight(15); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);//借方贷方的金额十列  第一行cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);//第二行cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);//第三行cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);//第四行cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);//第五行cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);//第六行cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);cell1 = new PdfPCell(new Phrase("", smallSixFont));cell1.setMinimumHeight(20); // 设置单元格高度cell1.setUseAscender(true); // 设置可以居中cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell1.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table1.addCell(cell1);//借方7行cell = new PdfPCell(new Phrase("", fiveFont));cell.setMinimumHeight(150); // 设置单元格高度cell.setUseAscender(true); // 设置可以居中cell.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell.setVerticalAlignment(Cell.ALIGN_TOP); // 设置垂直居中cell.setBorderWidthRight(0);cell.setBorderWidthLeft(0);cell.setBorderWidthBottom(0);cell.setPaddingLeft(2.5f);cell.setPaddingBottom(-3);cell.setRowspan(8);cell.addElement(table1);table.addCell(cell);//贷方发生  // 设计一个10列的表.PdfPTable table2 = new PdfPTable(10);table2.setWidthPercentage(102); // 宽度100%填充// 设置列宽float[] columnWidths2 = { 0.06f,0.06f,0.06f,0.06f,0.06f,0.06f,0.06f,0.06f,0.06f,0.06f};table2.setWidths(columnWidths2);PdfPCell cell2;cell2 = new PdfPCell(new Phrase("贷方发生", fiveFont));cell2.setMinimumHeight(13); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_TOP); // 设置垂直居中cell2.setColspan(10);table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("千", smallSixFont));cell2.setMinimumHeight(15); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("百", smallSixFont));cell2.setMinimumHeight(15); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("十", smallSixFont));cell2.setMinimumHeight(15); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("万", smallSixFont));cell2.setMinimumHeight(15); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("千", smallSixFont));cell2.setMinimumHeight(15); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("百", smallSixFont));cell2.setMinimumHeight(15); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("十", smallSixFont));cell2.setMinimumHeight(15); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("元", smallSixFont));cell2.setMinimumHeight(15); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("角", smallSixFont));cell2.setMinimumHeight(15); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("分", smallSixFont));cell2.setMinimumHeight(15); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);//借方贷方的金额十列  第一行cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);//第二行cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);//第三行cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);//第四行cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);//第五行cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);//第六行cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);cell2 = new PdfPCell(new Phrase("", smallSixFont));cell2.setMinimumHeight(20); // 设置单元格高度cell2.setUseAscender(true); // 设置可以居中cell2.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell2.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table2.addCell(cell2);//贷方7行cell = new PdfPCell(new Phrase("", fiveFont));cell.setMinimumHeight(150); // 设置单元格高度cell.setUseAscender(true); // 设置可以居中cell.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell.setVerticalAlignment(Cell.ALIGN_TOP); // 设置垂直居中cell.setBorderWidthLeft(0);cell.setBorderWidthBottom(0);cell.setPaddingRight(3);cell.setPaddingBottom(-3);cell.setRowspan(8);cell.addElement(table2);table.addCell(cell);// 设计一个10列的表.PdfPTable table4 = new PdfPTable(1);table4.setWidthPercentage(100); // 宽度100%填充// 设置列宽float[] columnWidths4 = { 1.6f};table4.setWidths(columnWidths4);PdfPCell cell4;cell4 = new PdfPCell(new Phrase("金额合计:捌佰陆拾壹元陆角玖分", fiveFont));cell4.setMinimumHeight(20); // 设置单元格高度cell4.setUseAscender(true); // 设置可以居中cell4.setHorizontalAlignment(Cell.ALIGN_LEFT); // 设置水平居中cell4.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table4.addCell(cell4);//最后一行cell = new PdfPCell(new Phrase("", fiveFont));cell.setBorderWidthRight(0);cell.setBorderWidthTop(0);cell.setPaddingRight(-0.2f);cell.setPaddingTop(-0.5f);cell.addElement(table4);cell.setColspan(2);table.addCell(cell);// 设计一个10列的表.PdfPTable table3 = new PdfPTable(10);table3.setWidthPercentage(102); // 宽度100%填充// 设置列宽float[] columnWidths3 = { 0.06f,0.06f,0.06f,0.06f,0.06f,0.06f,0.06f,0.06f,0.06f,0.06f};table3.setWidths(columnWidths3);PdfPCell cell3;cell3 = new PdfPCell(new Phrase("", smallSixFont));cell3.setMinimumHeight(20); // 设置单元格高度cell3.setUseAscender(true); // 设置可以居中cell3.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell3.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table3.addCell(cell3);cell3 = new PdfPCell(new Phrase("", smallSixFont));cell3.setMinimumHeight(20); // 设置单元格高度cell3.setUseAscender(true); // 设置可以居中cell3.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell3.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table3.addCell(cell3);cell3 = new PdfPCell(new Phrase("", smallSixFont));cell3.setMinimumHeight(20); // 设置单元格高度cell3.setUseAscender(true); // 设置可以居中cell3.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell3.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table3.addCell(cell3);cell3 = new PdfPCell(new Phrase("", smallSixFont));cell3.setMinimumHeight(20); // 设置单元格高度cell3.setUseAscender(true); // 设置可以居中cell3.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell3.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table3.addCell(cell3);cell3 = new PdfPCell(new Phrase("", smallSixFont));cell3.setMinimumHeight(20); // 设置单元格高度cell3.setUseAscender(true); // 设置可以居中cell3.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell3.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table3.addCell(cell3);cell3 = new PdfPCell(new Phrase("", smallSixFont));cell3.setMinimumHeight(20); // 设置单元格高度cell3.setUseAscender(true); // 设置可以居中cell3.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell3.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table3.addCell(cell3);cell3 = new PdfPCell(new Phrase("", smallSixFont));cell3.setMinimumHeight(20); // 设置单元格高度cell3.setUseAscender(true); // 设置可以居中cell3.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell3.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table3.addCell(cell3);cell3 = new PdfPCell(new Phrase("", smallSixFont));cell3.setMinimumHeight(20); // 设置单元格高度cell3.setUseAscender(true); // 设置可以居中cell3.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell3.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table3.addCell(cell3);cell3 = new PdfPCell(new Phrase("", smallSixFont));cell3.setMinimumHeight(20); // 设置单元格高度cell3.setUseAscender(true); // 设置可以居中cell3.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell3.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table3.addCell(cell3);cell3 = new PdfPCell(new Phrase("", smallSixFont));cell3.setMinimumHeight(20); // 设置单元格高度cell3.setUseAscender(true); // 设置可以居中cell3.setHorizontalAlignment(Cell.ALIGN_CENTER); // 设置水平居中cell3.setVerticalAlignment(Cell.ALIGN_MIDDLE); // 设置垂直居中table3.addCell(cell3);//借方cell = new PdfPCell(new Phrase("", smallFiveFont));cell.setBorderWidthRight(0);cell.setBorderWidthLeft(0);cell.setBorderWidthTop(0);cell.setPaddingLeft(2.5f);cell.setPaddingTop(-0.5f);cell.addElement(table3);table.addCell(cell);//贷方cell = new PdfPCell(new Phrase("", smallFiveFont));cell.setBorderWidthLeft(0);cell.setBorderWidthTop(0);cell.setPaddingTop(-0.5f);cell.setPaddingRight(3);cell.addElement(table3);table.addCell(cell);document.add(table);// 表尾Paragraph thrtionTitle = new Paragraph("制单:系统运维人员     审核:               记账:\n\n", fiveFont);thrtionTitle.setLeading(10);thrtionTitle.setAlignment(Element.ALIGN_LEFT);document.add(thrtionTitle);// 关闭文档document.close();// 关闭书写器writer.close();} catch (Exception e) {e.printStackTrace();throw new Exception();}return oldPath;}

author : su1573

使用PdfPCell,PdfPTable生成所需的pdf文件相关推荐

  1. python使用fpdf生成发票格式的pdf文件包含:文字、图片logo、表格、条形码等;

    python使用fpdf生成发票格式的pdf文件包含:文字.图片logo.表格.条形码等: pip install fpdf #python使用fpdf生成发票格式的pdf文件包含:文字.图片logo ...

  2. java根据pdf模板生成指定格式的pdf文件

    java根据pdf模板生成指定格式的pdf文件 一.工具准备 事先得准备好Adobe Acrobat DC,这是一款专门编辑pdf的工具,小编已经给大家准备好了. 链接:https://pan.bai ...

  3. Java 使用iText7生成带页码的PDF文件(同时生成目录,但是不会合并两个PDF)

    一.效果图 1.带页码效果 2.目录效果 前言:Java 使用iText7生成带页码的PDF文件,同时生成目录PDF,但限于水平,暂时还在摸索合并两个PDF.不过看了一下,iText好像有生成目录的代 ...

  4. Excel VBA自动化办公:选择Excel文件合并订单数据生成订单汇总表、生成发货单并导出pdf文件、自动统计业绩生成业绩表

    基本需求: 让用户可以选择多个文件,根据用户选中的工作簿进行合并订单数据,按照预先设计好的订单模板写入数据. 对于同一个交易序号下面有多个订单的,需要计算该交易序号下所有订单的总金额.总票数.相同交易 ...

  5. jFreeChart+itext生成带统计图的pdf文件

    jar包依赖 <!-- iText start--><!-- https://mvnrepository.com/artifact/com.itextpdf/itextpdf --& ...

  6. golang 生成本地保存的pdf文件,带图表

    pdf库和图表库介绍 pdf库: github.com/jung-kurt/gofpdf 图表库: github.com/wcharczuk/go-chart 最小pdf的官方示例 // 初始化一个p ...

  7. python根据模板生成pdf文件_如何使用ReportLab从各种页面模板生成PDF?

    我有JSON文件和大量数据和四个PDF模板的页面.我需要用所有这些数据和页面模板生成一个PDF文件.现在我的代码如下:self.line(self.data['sendr'], 10, 250, 25 ...

  8. flowable 中文文档_取出word文档文字内容生成加了目录、标号和页码的PDF文件

    word文档内的一页: 将文本取出来,生成自定义格式的PDF文件: 从word取出文本时标题的标号和页码是取不出来的,要自己加.另外就是目录也要自己生成和添加: 代码和解释如下: from repor ...

  9. 记-ItextPDF+freemaker 生成PDF文件---导致服务宕机

    摘要:已经上线的项目,出现服务挂掉的情况. 介绍:该服务是专门做打印的,业务需求是生成PDF文件进行页面预览,主要是使用ItextPDF+freemaker技术生成一系列PDF文件,其中生成流程有:解 ...

最新文章

  1. 全球互联正在创造一个知识极大丰富和隐私终结的时代
  2. java poi excel无法添加水印替代方法
  3. JAVASCRIPT实现绚丽TAB选项卡
  4. CODE[VS]-求和-整数处理-天梯青铜
  5. 博士论文:教你如何给女朋友送礼物
  6. C++ 重载函数调用运算符 | 再探lambda,函数对象,可调用对象
  7. 取文字_把这4个字母输入word,会得到一段神秘文字,承载着一段历史
  8. python音频分析工具_『开发技巧』Python音频操作工具PyAudio上手教程
  9. 修改windows默认远程管理端口
  10. python pdb查看变量值_如何用pdb进行python调试
  11. 点餐系统数据库设计--SQL Server
  12. 为什么很多人工资不高,却还是要拥挤在大城市生活?
  13. jquery fadein css同时用,如何同时运行jQuery fadeIn()和slideDown()?
  14. [算法]算法学习05
  15. winsxs是什么文件夹 Winsxs文件夹可以删除吗
  16. 推荐给中高级Python开发人员的自然语言处理书
  17. Java基础【08】常用API——RandomAccessFile相关API
  18. Unity tolua问题记录
  19. ArcGIS_空间插值分析
  20. 机房收费系统 项目总结

热门文章

  1. 双色球4:完成简单的产生随机幸运号码和判断中奖等级
  2. c语言 freopen txt_C语言文件操作函数freopen详解
  3. Caffe-SSD 安装过程
  4. 【饭谈-鸡血篇】先有技术?还是先有职级?
  5. 软件需求分析案列_软件需求分析与范例
  6. 理解fmt||net/http in Go
  7. centos7 r语言安装_【DS】Centos7服务器上安装R和Rstudio
  8. python中functools_python functools模块
  9. 嘿嘿嘿,微软创新秀倒计时2天咯
  10. 飞奔的B站:正在崛起的投资巨头