一、準備生成的文件
二、分析文件結構
在文件中,
- 文件標題下面用雙劃線標識
- 表格外圍邊框也是雙線
- 右側的兩個密集的單元格,外圍也是雙線
三、提出解決方法
- 設想使用pdfPTable某些屬性或方法,設置邊框雙線;
經測試,未找到有效的解決屬性和方法;此方法泡湯 - 使用單元格內套表格的方式
經測試,此方法可成
四、具體代碼實現
代碼量較多,可以粘貼到自己的編譯器中進行測試
// 生成記賬憑證
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);
//2222222222
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);
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