Java iText5.5.1 绘制PDF表格

iText下载链接:http://sourceforge.net/projects/itext/files/

会有两个文件夹:extrajars中的extrajars-2.3.jar文件用于解决中文不显示的问题。

将下载的itext-5.5.1文件解压之后,将itextpdf-5.5.1.jar导入就可以使用了。

由于在使用过程中没有API 参考,以及网上的资料都是之前老版本的,所以一些用法都是经过不断的尝试得出来的。

要生成的PDF表格如下两幅图所示:

iText简单介绍:

(1) iText中用文本块(Chunk)、短语(Phrase)和段落(paragraph)处理文本;

(2)文本块(Chunk)是处理文本的最小单位,有一串带格式(包括字体、颜色、大小)的字符串组成;

(3)短语(Phrase)由一个或多个文本块(Chunk)组成,短语(Phrase)也可以设定字体,但对于其中以设定过字体的文本块(Chunk)无效;

(4)段落(paragraph)由一个或多个文本块(Chunk)或短语(Phrase)组成,相当于WORD文档中的段落概念,同样可以设定段落的字体大小、颜色等属性。 另外也可以设定段落的首行缩进、对齐方式(左对齐、右对齐、居中对齐)。通过函数setAlignment可以设定段落的对齐方式, setAlignment的参数1为居中对齐、2为右对齐、3为左对齐,默认为左对齐。

(5)表格(PdfPTable),通过添加列(PdfPCell)来拼凑表格,顺序是从左到右、从上到下,可以通过setBorderWidth()方法设置列的边框宽度,setRowspan()设置此列横跨几行,setColspan()设置此列横跨几列。对于列的详细设置可以通过.set查看。

代码:一个工具类

   1 public class FpdkImportPDF {
   2 
   3     /**
   4      * 代开增值税专用发票缴纳税款申报单
   5      */
   6     public static void dkzzszyfp() {
   7         // 1:建立Document对象实例
   8         Document document = new Document();
   9         try {
  10             // 2:建立一个PDF 写入器与document对象关联通过书写器(Writer)可以将文档写入到磁盘中
  11             StringBuilder filename = new StringBuilder();
  12             filename.append("代开增值税专用发票缴纳税款申报单").append(new SimpleDateFormat("yyyyMMddHHmm").format(new Date())).append(".pdf");
  13             PdfWriter.getInstance(document, new FileOutputStream(filename.toString()));
  14             
  15             // 3:打开文档
  16             document.open();
  17             
  18             //解决中文不显示问题
  19             BaseFont bfChinese = BaseFont.createFont("STSong-Light","UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
  20             Font fontChina18 = new Font(bfChinese, 18);
  21             Font fontChina12 = new Font(bfChinese, 12);
  22             
  23             // 4:向文档添加内容
  24             // 标题
  25             Paragraph titleParagraph = new Paragraph("代开增值税专用发票缴纳税款申报单",fontChina18);
  26             titleParagraph.setAlignment(Element.ALIGN_CENTER);// 居中
  27             document.add(titleParagraph);
  28             
  29             // 空格
  30             Paragraph blank1 = new Paragraph(" ");
  31             document.add(blank1);
  32             
  33             // 编号
  34             Chunk c1 = new Chunk("编号:", fontChina12);
  35             Chunk c2 = new Chunk("20140531001", fontChina12);
  36             Paragraph snoParagraph = new Paragraph();
  37             snoParagraph.add(c1);
  38             snoParagraph.add(c2);
  39             snoParagraph.setAlignment(Element.ALIGN_RIGHT);
  40             document.add(snoParagraph);
  41 
  42             // 空格
  43             document.add(blank1);
  44 
  45             // 代开税务机关
  46             Chunk c3 = new Chunk("代开税务机关名称:青岛经济技术开发区国税局", fontChina12);
  47             Paragraph dkswjgParagraph = new Paragraph();
  48             dkswjgParagraph.add(c3);
  49             dkswjgParagraph.setAlignment(Element.ALIGN_LEFT);
  50             document.add(dkswjgParagraph);
  51 
  52             // 提醒
  53             String alert = "我单位提供的开票资料真实、完整、准确,符合有关法律、法规,否则我单位将承担一切法律责任,现申请代开增值税专用发票。";
  54             Paragraph alertParagraph = new Paragraph(alert, fontChina12);
  55             alertParagraph.setFirstLineIndent(24);// 首行缩进个2字符
  56             document.add(alertParagraph);
  57 
  58             // 填开日期
  59             Chunk c5 = new Chunk("填开日期:2014年05月31日", fontChina12);
  60             Paragraph tkrqParagraph = new Paragraph();
  61             tkrqParagraph.add(c5);
  62             tkrqParagraph.setAlignment(Element.ALIGN_RIGHT);
  63             document.add(tkrqParagraph);
  64             
  65             // 空格
  66             document.add(blank1);
  67 
  68             // 表格处理
  69             PdfPTable table = new PdfPTable(8);// 八列
  70             table.setWidthPercentage(100);// 表格宽度为100%
  71             
  72             // 购货单位
  73             PdfPCell cell1 = new PdfPCell();
  74             cell1.setBorderWidth(1);// Border宽度为1
  75             cell1.setRowspan(3);// 跨三行
  76             cell1.setPhrase(new Paragraph("购货单位", fontChina12));
  77             cell1.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
  78             cell1.setExtraParagraphSpace(10);
  79             table.addCell(cell1);
  80 
  81             PdfPCell cell2 = new PdfPCell();
  82             cell2.setBorderWidth(1);
  83             cell2.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
  84             cell2.setPhrase(new Paragraph("名称", fontChina12));
  85             table.addCell(cell2);
  86             PdfPCell cell3 = new PdfPCell();
  87             cell3.setBorderWidth(1);
  88             cell3.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
  89             cell3.setColspan(3);// 跨三列
  90             cell3.setPhrase(new Paragraph("名称", fontChina12));
  91             table.addCell(cell3);
  92 
  93             PdfPCell cell4 = new PdfPCell();
  94             cell4.setBorderWidth(1);
  95             cell4.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
  96             cell4.setPhrase(new Paragraph("税务登记号", fontChina12));
  97             table.addCell(cell4);
  98             PdfPCell cell5 = new PdfPCell();
  99             cell5.setBorderWidth(1);
 100             cell5.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 101             cell5.setColspan(2);// 跨两列
 102             cell5.setPhrase(new Paragraph("税务登记号", fontChina12));
 103             table.addCell(cell5);
 104 
 105             PdfPCell cell6 = new PdfPCell();
 106             cell6.setBorderWidth(1);
 107             cell6.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 108             cell6.setPhrase(new Paragraph("地址", fontChina12));
 109             table.addCell(cell6);
 110             PdfPCell cell7 = new PdfPCell();
 111             cell7.setBorderWidth(1);
 112             cell7.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 113             cell7.setColspan(3);// 跨三列
 114             cell7.setPhrase(new Paragraph("地址", fontChina12));
 115             table.addCell(cell7);
 116 
 117             PdfPCell cell8 = new PdfPCell();
 118             cell8.setBorderWidth(1);
 119             cell8.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 120             cell8.setPhrase(new Paragraph("开户银行", fontChina12));
 121             table.addCell(cell8);
 122             PdfPCell cell9 = new PdfPCell();
 123             cell9.setBorderWidth(1);
 124             cell9.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 125             cell9.setColspan(2);// 跨两列
 126             cell9.setPhrase(new Paragraph("开户银行", fontChina12));
 127             table.addCell(cell9);
 128 
 129             PdfPCell cell10 = new PdfPCell();
 130             cell10.setBorderWidth(1);
 131             cell10.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 132             cell10.setPhrase(new Paragraph("电话", fontChina12));
 133             table.addCell(cell10);
 134             PdfPCell cell11 = new PdfPCell();
 135             cell11.setBorderWidth(1);
 136             cell11.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 137             cell11.setColspan(3);// 跨三列
 138             cell11.setPhrase(new Paragraph("电话", fontChina12));
 139             table.addCell(cell11);
 140 
 141             PdfPCell cell12 = new PdfPCell();
 142             cell12.setBorderWidth(1);
 143             cell12.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 144             cell12.setPhrase(new Paragraph("开户银行账号", fontChina12));
 145             table.addCell(cell12);
 146             PdfPCell cell13 = new PdfPCell();
 147             cell13.setBorderWidth(1);
 148             cell13.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 149             cell13.setColspan(2);// 跨两列
 150             cell13.setPhrase(new Paragraph("开户银行账号", fontChina12));
 151             table.addCell(cell13);
 152 
 153             // 货物或应税劳务信息
 154             // Row1
 155             PdfPCell cell14 = new PdfPCell();
 156             cell14.setBorderWidth(1);
 157             cell14.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 158             cell14.setPhrase(new Paragraph("货物或应税劳务名称", fontChina12));
 159             table.addCell(cell14);
 160             PdfPCell cell15 = new PdfPCell();
 161             cell15.setBorderWidth(1);
 162             cell15.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 163             cell15.setPhrase(new Paragraph("规格型号", fontChina12));
 164             table.addCell(cell15);
 165             PdfPCell cell16 = new PdfPCell();
 166             cell16.setBorderWidth(1);
 167             cell16.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 168             cell16.setPhrase(new Paragraph("计量单位", fontChina12));
 169             table.addCell(cell16);
 170             PdfPCell cell17 = new PdfPCell();
 171             cell17.setBorderWidth(1);
 172             cell17.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 173             cell17.setPhrase(new Paragraph("数量", fontChina12));
 174             table.addCell(cell17);
 175             PdfPCell cell18 = new PdfPCell();
 176             cell18.setBorderWidth(1);
 177             cell18.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 178             cell18.setPhrase(new Paragraph("单价", fontChina12));
 179             table.addCell(cell18);
 180             PdfPCell cell19 = new PdfPCell();
 181             cell19.setBorderWidth(1);
 182             cell19.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 183             cell19.setPhrase(new Paragraph(" 金额", fontChina12));
 184             table.addCell(cell19);
 185             PdfPCell cell20 = new PdfPCell();
 186             cell20.setBorderWidth(1);
 187             cell20.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 188             cell20.setPhrase(new Paragraph("征收率", fontChina12));
 189             table.addCell(cell20);
 190             PdfPCell cell21 = new PdfPCell();
 191             cell21.setBorderWidth(1);
 192             cell21.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 193             cell21.setPhrase(new Paragraph("税额", fontChina12));
 194             table.addCell(cell21);
 195             // Row2 填写数据
 196             PdfPCell cell22 = new PdfPCell();
 197             cell22.setBorderWidth(1);
 198             cell22.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 199             cell22.setPhrase(new Paragraph("货物或应税劳务名称", fontChina12));
 200             table.addCell(cell22);
 201             PdfPCell cell23 = new PdfPCell();
 202             cell23.setBorderWidth(1);
 203             cell23.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 204             cell23.setPhrase(new Paragraph("规格型号", fontChina12));
 205             table.addCell(cell23);
 206             PdfPCell cell24 = new PdfPCell();
 207             cell24.setBorderWidth(1);
 208             cell24.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 209             cell24.setPhrase(new Paragraph("计量单位", fontChina12));
 210             table.addCell(cell24);
 211             PdfPCell cell25 = new PdfPCell();
 212             cell25.setBorderWidth(1);
 213             cell25.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 214             cell25.setPhrase(new Paragraph("数量", fontChina12));
 215             table.addCell(cell25);
 216             PdfPCell cell26 = new PdfPCell();
 217             cell26.setBorderWidth(1);
 218             cell26.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 219             cell26.setPhrase(new Paragraph("单价", fontChina12));
 220             table.addCell(cell26);
 221             PdfPCell cell27 = new PdfPCell();
 222             cell27.setBorderWidth(1);
 223             cell27.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 224             cell27.setPhrase(new Paragraph(" 金额", fontChina12));
 225             table.addCell(cell27);
 226             PdfPCell cell28 = new PdfPCell();
 227             cell28.setBorderWidth(1);
 228             cell28.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 229             cell28.setPhrase(new Paragraph("征收率", fontChina12));
 230             table.addCell(cell28);
 231             PdfPCell cell29 = new PdfPCell();
 232             cell29.setBorderWidth(1);
 233             cell29.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 234             cell29.setPhrase(new Paragraph("税额", fontChina12));
 235             table.addCell(cell29);
 236 
 237             // 价税合计
 238             PdfPCell cell30 = new PdfPCell();
 239             cell30.setBorderWidth(1);
 240             cell30.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 241             cell30.setPhrase(new Paragraph("价税合计(大写)", fontChina12));
 242             table.addCell(cell30);
 243             PdfPCell cell31 = new PdfPCell();
 244             cell31.setBorderWidth(1);
 245             cell31.setColspan(4);// 跨四列
 246             cell31.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 247             cell31.setPhrase(new Paragraph("价税合计(大写)", fontChina12));
 248             table.addCell(cell31);
 249             PdfPCell cell32 = new PdfPCell();
 250             cell32.setBorderWidth(1);
 251             cell32.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 252             cell32.setPhrase(new Paragraph("价税合计(小写)", fontChina12));
 253             table.addCell(cell32);
 254             PdfPCell cell33 = new PdfPCell();
 255             cell33.setBorderWidth(1);
 256             cell33.setColspan(2);// 跨两列
 257             cell33.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 258             cell33.setPhrase(new Paragraph("价税合计(小写)", fontChina12));
 259             table.addCell(cell33);
 260             // 备注
 261             PdfPCell cell34 = new PdfPCell();
 262             cell34.setBorderWidth(1);
 263             cell34.setMinimumHeight(40);
 264             cell34.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 265             cell34.setPhrase(new Paragraph("备注", fontChina12));
 266             table.addCell(cell34);
 267             PdfPCell cell35 = new PdfPCell();
 268             cell35.setBorderWidth(1);
 269             cell35.setColspan(7);
 270             cell35.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 271             cell35.setPhrase(new Paragraph("备注", fontChina12));
 272             table.addCell(cell35);
 273 
 274             // 销货单位
 275             PdfPCell cell36 = new PdfPCell();
 276             cell36.setBorderWidth(1);// Border宽度为1
 277             cell36.setRowspan(3);// 跨三行
 278             cell36.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 279             cell36.setPhrase(new Paragraph("销货单位", fontChina12));
 280             table.addCell(cell36);
 281 
 282             PdfPCell cell37 = new PdfPCell();
 283             cell37.setBorderWidth(1);
 284             cell37.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 285             cell37.setPhrase(new Paragraph("名称", fontChina12));
 286             table.addCell(cell37);
 287             PdfPCell cell38 = new PdfPCell();
 288             cell38.setBorderWidth(1);
 289             cell38.setColspan(3);// 跨三列
 290             cell38.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 291             cell38.setPhrase(new Paragraph("名称", fontChina12));
 292             table.addCell(cell38);
 293 
 294             PdfPCell cell39 = new PdfPCell();
 295             cell39.setBorderWidth(1);
 296             cell39.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 297             cell39.setPhrase(new Paragraph("税务登记号", fontChina12));
 298             table.addCell(cell39);
 299             PdfPCell cell40 = new PdfPCell();
 300             cell40.setBorderWidth(1);
 301             cell40.setColspan(2);// 跨两列
 302             cell40.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 303             cell40.setPhrase(new Paragraph("税务登记号", fontChina12));
 304             table.addCell(cell40);
 305 
 306             PdfPCell cell41 = new PdfPCell();
 307             cell41.setBorderWidth(1);
 308             cell41.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 309             cell41.setPhrase(new Paragraph("地址", fontChina12));
 310             table.addCell(cell41);
 311             PdfPCell cell42 = new PdfPCell();
 312             cell42.setBorderWidth(1);
 313             cell42.setColspan(3);// 跨三列
 314             cell42.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 315             cell42.setPhrase(new Paragraph("地址", fontChina12));
 316             table.addCell(cell42);
 317 
 318             PdfPCell cell43 = new PdfPCell();
 319             cell43.setBorderWidth(1);
 320             cell43.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 321             cell43.setPhrase(new Paragraph("开户银行", fontChina12));
 322             table.addCell(cell43);
 323             PdfPCell cell44 = new PdfPCell();
 324             cell44.setBorderWidth(1);
 325             cell44.setColspan(2);// 跨两列
 326             cell44.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 327             cell44.setPhrase(new Paragraph("开户银行", fontChina12));
 328             table.addCell(cell44);
 329 
 330             PdfPCell cell45 = new PdfPCell();
 331             cell45.setBorderWidth(1);
 332             cell45.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 333             cell45.setPhrase(new Paragraph("电话", fontChina12));
 334             table.addCell(cell45);
 335             PdfPCell cell46 = new PdfPCell();
 336             cell46.setBorderWidth(1);
 337             cell46.setColspan(3);// 跨三列
 338             cell46.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 339             cell46.setPhrase(new Paragraph("电话", fontChina12));
 340             table.addCell(cell46);
 341 
 342             PdfPCell cell47 = new PdfPCell();
 343             cell47.setBorderWidth(1);
 344             cell47.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 345             cell47.setPhrase(new Paragraph("开户银行账号", fontChina12));
 346             table.addCell(cell47);
 347             PdfPCell cell48 = new PdfPCell();
 348             cell48.setBorderWidth(1);
 349             cell48.setColspan(2);// 跨两列
 350             cell48.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 351             cell48.setPhrase(new Paragraph("开户银行账号", fontChina12));
 352             table.addCell(cell48);
 353 
 354             // 底部
 355             Paragraph pQz = new Paragraph("(签字)", fontChina12);
 356             pQz.setAlignment(Element.ALIGN_RIGHT);
 357             pQz.setIndentationRight(20);
 358             pQz.setExtraParagraphSpace(60);
 359             
 360             Paragraph pJbrQz = new Paragraph("申请经办人(签字)", fontChina12);
 361             pJbrQz.setAlignment(Element.ALIGN_RIGHT);
 362             pJbrQz.setIndentationRight(20);
 363             pJbrQz.setExtraParagraphSpace(60);
 364             
 365             Paragraph pDate = new Paragraph(" 年   月   日", fontChina12);
 366             pDate.setAlignment(Element.ALIGN_RIGHT);
 367             pQz.setIndentationRight(20);
 368             
 369             PdfPCell cellF1 = new PdfPCell();
 370             cellF1.setBorderWidth(1);
 371             cellF1.setColspan(2);
 372             cellF1.setFixedHeight(200);//
 373             Paragraph p0 = new Paragraph("税务机关税款征收岗位税收完税凭证号:", fontChina12);
 374             cellF1.addElement(p0);
 375             cellF1.addElement(blank1);
 376             cellF1.addElement(blank1);
 377             cellF1.addElement(blank1);
 378             cellF1.addElement(pQz);
 379             cellF1.addElement(pDate);
 380             table.addCell(cellF1);
 381             
 382             PdfPCell cellF2 = new PdfPCell();
 383             cellF2.setBorderWidth(1);
 384             cellF2.setColspan(3);
 385             Paragraph p1 = new Paragraph("税务机关代开发票岗位", fontChina12);
 386             Paragraph p2 = new Paragraph("发票代码: ", fontChina12);
 387             Paragraph p3 = new Paragraph("发票号码: ", fontChina12);
 388             cellF2.addElement(p1);
 389             cellF2.addElement(p2);
 390             cellF2.addElement(p3);
 391             cellF2.addElement(blank1);
 392             cellF2.addElement(blank1);
 393             cellF2.addElement(pQz);
 394             cellF2.addElement(pDate);
 395             table.addCell(cellF2);
 396             
 397             PdfPCell cellF3 = new PdfPCell();
 398             cellF3.setBorderWidth(1);
 399             cellF3.setColspan(3);
 400             Paragraph p4 = new Paragraph("经核对,所开发票与申报单内容一致。", fontChina12); 
 401             p4.setFirstLineIndent(24);
 402             cellF3.addElement(p4);
 403             cellF3.addElement(blank1);
 404             cellF3.addElement(blank1);
 405             cellF3.addElement(blank1);
 406             cellF3.addElement(pJbrQz);
 407             cellF3.addElement(pDate);
 408             table.addCell(cellF3);
 409             
 410             document.add(table);
 411 
 412             document.add(blank1);
 413             
 414             //底部额外信息
 415             StringBuilder sb1 = new StringBuilder();
 416             sb1.append("申请代开发票纳税人(公章)_________");
 417             sb1.append("法人代表_________");
 418             sb1.append("财务负责人_________");
 419             sb1.append("填写人_________");
 420             Paragraph pE = new Paragraph(sb1.toString(),fontChina12);
 421             pE.setAlignment(Element.ALIGN_CENTER);
 422             document.add(pE);
 423             
 424             document.add(blank1);
 425             
 426             //
 427             StringBuilder sb2 = new StringBuilder();
 428             sb2.append("注:第一联:税务机关代开发票岗位留存。");
 429             sb2.append("第二联:税务机关税款征收岗位留存。");
 430             Paragraph pZ = new Paragraph(sb2.toString(),fontChina12);
 431             pZ.setAlignment(Element.ALIGN_CENTER);
 432             document.add(pZ);
 433             
 434             // 5:关闭文档
 435             document.close();
 436         } catch (FileNotFoundException e) {
 437             e.printStackTrace();
 438         } catch (DocumentException e) {
 439             e.printStackTrace();
 440         } catch (IOException e) {
 441             e.printStackTrace();
 442         }
 443     }
 444 
 445     /**
 446      * 代开货物运输业增值税专用发票及缴纳税款申报单
 447      */
 448     public static void dkhyzzszyfp() {
 449         Document document = new Document();
 450         try {
 451             // 2:建立一个PDF 写入器与document对象关联通过书写器(Writer)可以将文档写入到磁盘中
 452             StringBuilder filename = new StringBuilder();
 453             filename.append("代开货物运输业增值税专用发票及缴纳税款申报单").append(new SimpleDateFormat("yyyyMMddHHmm").format(new Date())).append(".pdf");
 454             PdfWriter.getInstance(document, new FileOutputStream(filename.toString()));
 455             
 456             // 3:打开文档
 457             document.open();
 458             
 459             //解决中文不显示问题
 460             BaseFont bfChinese = BaseFont.createFont("STSong-Light","UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
 461             Font fontChina18 = new Font(bfChinese, 18);
 462             Font fontChina12 = new Font(bfChinese, 12);
 463             
 464             // 4:向文档添加内容
 465             // 标题
 466             Paragraph titleParagraph = new Paragraph("代开货物运输业增值税专用发票及缴纳税款申报单",fontChina18);
 467             titleParagraph.setAlignment(Element.ALIGN_CENTER);// 居中
 468             document.add(titleParagraph);
 469             
 470             // 空格
 471             Paragraph blank1 = new Paragraph(" ");
 472             document.add(blank1);
 473             
 474             // 填开日期
 475             Chunk c1 = new Chunk("填开日期:2014年05月31日", fontChina12);
 476             Chunk c2 = new Chunk("   金额单位:元至角分", fontChina12);
 477             Paragraph snoParagraph = new Paragraph();
 478             snoParagraph.add(c1);
 479             snoParagraph.add(c2);
 480             snoParagraph.setAlignment(Element.ALIGN_RIGHT);
 481             document.add(snoParagraph);
 482             
 483             // 空格
 484             document.add(blank1);
 485 
 486             // 表格处理
 487             PdfPTable table = new PdfPTable(6);// 六列
 488             table.setWidthPercentage(100);// 表格宽度为100%
 489             
 490             //以下由纳税人填写
 491             PdfPCell cell1 = new PdfPCell();
 492             cell1.setBorderWidth(1);// Border宽度为1
 493             cell1.setColspan(6);//跨六列
 494             cell1.setPhrase(new Paragraph("以下由纳税人填写", fontChina12));
 495             cell1.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 496             cell1.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
 497             table.addCell(cell1);
 498             
 499             //实际受票方
 500             PdfPCell cell2 = new PdfPCell();
 501             cell2.setBorderWidth(1);
 502             cell2.setRowspan(4);//跨四行
 503             cell2.setPhrase(new Paragraph("实际受票方", fontChina12));
 504             cell2.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 505             table.addCell(cell2);
 506             
 507             PdfPCell cell3 = new PdfPCell();
 508             cell3.setBorderWidth(1);
 509             cell3.setPhrase(new Paragraph("纳税人全称", fontChina12));
 510             cell3.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 511             table.addCell(cell3);
 512             PdfPCell cell4 = new PdfPCell();
 513             cell4.setBorderWidth(1);
 514             cell4.setColspan(4);//跨四列
 515             cell4.setPhrase(new Paragraph("纳税人全称", fontChina12));
 516             cell4.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 517             table.addCell(cell4);
 518             
 519             PdfPCell cell5 = new PdfPCell();
 520             cell5.setBorderWidth(1);
 521             cell5.setPhrase(new Paragraph("纳税人识别号", fontChina12));
 522             cell5.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 523             table.addCell(cell5);
 524             PdfPCell cell6 = new PdfPCell();
 525             cell6.setBorderWidth(1);
 526             cell6.setColspan(4);//跨四列
 527             cell6.setPhrase(new Paragraph("纳税人识别号", fontChina12));
 528             cell6.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 529             table.addCell(cell6);
 530             
 531             PdfPCell cell7 = new PdfPCell();
 532             cell7.setBorderWidth(1);
 533             cell7.setPhrase(new Paragraph("地址、电话", fontChina12));
 534             cell7.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 535             table.addCell(cell7);
 536             PdfPCell cell8 = new PdfPCell();
 537             cell8.setBorderWidth(1);
 538             cell8.setColspan(4);//跨四列
 539             cell8.setPhrase(new Paragraph("地址、电话", fontChina12));
 540             cell8.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 541             table.addCell(cell8);
 542             
 543             PdfPCell cell9 = new PdfPCell();
 544             cell9.setBorderWidth(1);
 545             cell9.setPhrase(new Paragraph("开户行及帐号", fontChina12));
 546             cell9.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 547             table.addCell(cell9);
 548             PdfPCell cell10 = new PdfPCell();
 549             cell10.setBorderWidth(1);
 550             cell10.setColspan(4);//跨四列
 551             cell10.setPhrase(new Paragraph("开户行及帐号", fontChina12));
 552             cell10.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 553             table.addCell(cell10);
 554             
 555             //承运人
 556             PdfPCell cell11 = new PdfPCell();
 557             cell11.setBorderWidth(1);
 558             cell11.setRowspan(4);//跨四行
 559             cell11.setPhrase(new Paragraph("承运人", fontChina12));
 560             cell11.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 561             table.addCell(cell11);
 562             
 563             PdfPCell cell12 = new PdfPCell();
 564             cell12.setBorderWidth(1);
 565             cell12.setPhrase(new Paragraph("纳税人全称", fontChina12));
 566             cell12.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 567             table.addCell(cell12);
 568             PdfPCell cell13 = new PdfPCell();
 569             cell13.setBorderWidth(1);
 570             cell13.setColspan(4);//跨四列
 571             cell13.setPhrase(new Paragraph("纳税人全称", fontChina12));
 572             cell13.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 573             table.addCell(cell13);
 574             
 575             PdfPCell cell14 = new PdfPCell();
 576             cell14.setBorderWidth(1);
 577             cell14.setPhrase(new Paragraph("纳税人识别号", fontChina12));
 578             cell14.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 579             table.addCell(cell14);
 580             PdfPCell cell15 = new PdfPCell();
 581             cell15.setBorderWidth(1);
 582             cell15.setColspan(4);//跨四列
 583             cell15.setPhrase(new Paragraph("纳税人识别号", fontChina12));
 584             cell15.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 585             table.addCell(cell15);
 586             
 587             PdfPCell cell16 = new PdfPCell();
 588             cell16.setBorderWidth(1);
 589             cell16.setPhrase(new Paragraph("地址、电话", fontChina12));
 590             cell16.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 591             table.addCell(cell16);
 592             PdfPCell cell17 = new PdfPCell();
 593             cell17.setBorderWidth(1);
 594             cell17.setColspan(4);//跨四列
 595             cell17.setPhrase(new Paragraph("地址、电话", fontChina12));
 596             cell17.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 597             table.addCell(cell17);
 598             
 599             PdfPCell cell18 = new PdfPCell();
 600             cell18.setBorderWidth(1);
 601             cell18.setPhrase(new Paragraph("开户行及帐号", fontChina12));
 602             cell18.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 603             table.addCell(cell18);
 604             PdfPCell cell19 = new PdfPCell();
 605             cell19.setBorderWidth(1);
 606             cell19.setColspan(4);//跨四列
 607             cell19.setPhrase(new Paragraph("开户行及帐号", fontChina12));
 608             cell19.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 609             table.addCell(cell19);
 610             
 611             //发货人
 612             PdfPCell cell20 = new PdfPCell();
 613             cell20.setBorderWidth(1);
 614             cell20.setRowspan(2);//跨2行
 615             cell20.setPhrase(new Paragraph("发货人", fontChina12));
 616             cell20.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 617             table.addCell(cell20);
 618             
 619             PdfPCell cell21 = new PdfPCell();
 620             cell21.setBorderWidth(1);
 621             cell21.setPhrase(new Paragraph("纳税人全称", fontChina12));
 622             cell21.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 623             table.addCell(cell21);
 624             PdfPCell cell22 = new PdfPCell();
 625             cell22.setBorderWidth(1);
 626             cell22.setColspan(4);//跨四列
 627             cell22.setPhrase(new Paragraph("纳税人全称", fontChina12));
 628             cell22.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 629             table.addCell(cell22);
 630             
 631             PdfPCell cell23 = new PdfPCell();
 632             cell23.setBorderWidth(1);
 633             cell23.setPhrase(new Paragraph("纳税人识别号", fontChina12));
 634             cell23.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 635             table.addCell(cell23);
 636             PdfPCell cell24 = new PdfPCell();
 637             cell24.setBorderWidth(1);
 638             cell24.setColspan(4);//跨四列
 639             cell24.setPhrase(new Paragraph("纳税人识别号", fontChina12));
 640             cell24.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 641             table.addCell(cell24);
 642             
 643             //收货人
 644             PdfPCell cell25 = new PdfPCell();
 645             cell25.setBorderWidth(1);
 646             cell25.setRowspan(4);//跨四行
 647             cell25.setPhrase(new Paragraph("收货人", fontChina12));
 648             cell25.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 649             table.addCell(cell25);
 650             
 651             PdfPCell cell26 = new PdfPCell();
 652             cell26.setBorderWidth(1);
 653             cell26.setPhrase(new Paragraph("纳税人全称", fontChina12));
 654             cell26.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 655             table.addCell(cell26);
 656             PdfPCell cell27 = new PdfPCell();
 657             cell27.setBorderWidth(1);
 658             cell27.setColspan(4);//跨四列
 659             cell27.setPhrase(new Paragraph("纳税人全称", fontChina12));
 660             cell27.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 661             table.addCell(cell27);
 662             
 663             PdfPCell cell28 = new PdfPCell();
 664             cell28.setBorderWidth(1);
 665             cell28.setPhrase(new Paragraph("纳税人识别号", fontChina12));
 666             cell28.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 667             table.addCell(cell28);
 668             PdfPCell cell29 = new PdfPCell();
 669             cell29.setBorderWidth(1);
 670             cell29.setColspan(4);//跨四列
 671             cell29.setPhrase(new Paragraph("纳税人识别号", fontChina12));
 672             cell29.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 673             table.addCell(cell29);
 674             
 675             PdfPCell cell30 = new PdfPCell();
 676             cell30.setBorderWidth(1);
 677             cell30.setPhrase(new Paragraph("地址、电话", fontChina12));
 678             cell30.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 679             table.addCell(cell30);
 680             PdfPCell cell31 = new PdfPCell();
 681             cell31.setBorderWidth(1);
 682             cell31.setColspan(4);//跨四列
 683             cell31.setPhrase(new Paragraph("地址、电话", fontChina12));
 684             cell31.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 685             table.addCell(cell31);
 686             
 687             PdfPCell cell32 = new PdfPCell();
 688             cell32.setBorderWidth(1);
 689             cell32.setPhrase(new Paragraph("开户行及帐号", fontChina12));
 690             cell32.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 691             table.addCell(cell32);
 692             PdfPCell cell33 = new PdfPCell();
 693             cell33.setBorderWidth(1);
 694             cell33.setColspan(4);//跨四列
 695             cell33.setPhrase(new Paragraph("开户行及帐号", fontChina12));
 696             cell33.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 697             table.addCell(cell33);
 698             
 699             //起运地、经由、到达地
 700             PdfPCell cell34 = new PdfPCell();
 701             cell34.setBorderWidth(1);
 702             cell34.setColspan(2);//跨2列
 703             cell34.setPhrase(new Paragraph("起运地、经由、到达地", fontChina12));
 704             cell34.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 705             table.addCell(cell34);
 706             PdfPCell cell35 = new PdfPCell();
 707             cell35.setBorderWidth(1);
 708             cell35.setColspan(4);//跨四列
 709             cell35.setPhrase(new Paragraph("起运地、经由、到达地", fontChina12));
 710             cell35.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 711             table.addCell(cell35);
 712             
 713             
 714             //费用项目信息 -Title
 715             PdfPCell cell36 = new PdfPCell();
 716             cell36.setBorderWidth(1);
 717             cell36.setPhrase(new Paragraph("费用项目名称", fontChina12));
 718             cell36.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 719             table.addCell(cell36);
 720             PdfPCell cell37 = new PdfPCell();
 721             cell37.setBorderWidth(1);
 722             cell37.setPhrase(new Paragraph("费用项目金额(不含税)", fontChina12));
 723             cell37.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 724             table.addCell(cell37);
 725             PdfPCell cell38 = new PdfPCell();
 726             cell38.setBorderWidth(1);
 727             cell38.setPhrase(new Paragraph("运输货物信息", fontChina12));
 728             cell38.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 729             table.addCell(cell38);
 730             PdfPCell cell39 = new PdfPCell();
 731             cell39.setBorderWidth(1);
 732             cell39.setPhrase(new Paragraph("合计金额(不含税销售额合计)称", fontChina12));
 733             cell39.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 734             table.addCell(cell39);
 735             PdfPCell cell40 = new PdfPCell();
 736             cell40.setBorderWidth(1);
 737             cell40.setPhrase(new Paragraph("征收率", fontChina12));
 738             cell40.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 739             table.addCell(cell40);
 740             PdfPCell cell41 = new PdfPCell();
 741             cell41.setBorderWidth(1);
 742             cell41.setPhrase(new Paragraph("增值税应纳税额", fontChina12));
 743             cell41.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 744             table.addCell(cell41);
 745             //费用项目信息-Alert
 746             PdfPCell cell42 = new PdfPCell();
 747             cell42.setBorderWidth(1);
 748             cell42.setPhrase(new Paragraph("1", fontChina12));
 749             cell42.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 750             table.addCell(cell42);
 751             PdfPCell cell43 = new PdfPCell();
 752             cell43.setBorderWidth(1);
 753             cell43.setPhrase(new Paragraph("2", fontChina12));
 754             cell43.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 755             table.addCell(cell43);
 756             PdfPCell cell44 = new PdfPCell();
 757             cell44.setBorderWidth(1);
 758             cell44.setPhrase(new Paragraph("3", fontChina12));
 759             cell44.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 760             table.addCell(cell44);
 761             PdfPCell cell45 = new PdfPCell();
 762             cell45.setBorderWidth(1);
 763             cell45.setPhrase(new Paragraph("4", fontChina12));
 764             cell45.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 765             table.addCell(cell45);
 766             PdfPCell cell46 = new PdfPCell();
 767             cell46.setBorderWidth(1);
 768             cell46.setPhrase(new Paragraph("5", fontChina12));
 769             cell46.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 770             table.addCell(cell46);
 771             PdfPCell cell47 = new PdfPCell();
 772             cell47.setBorderWidth(1);
 773             cell47.setPhrase(new Paragraph("6=4×5", fontChina12));
 774             cell47.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 775             table.addCell(cell47);
 776             //费用项目信息-Input
 777             PdfPCell cell48 = new PdfPCell();
 778             cell48.setBorderWidth(1);
 779             cell48.setPhrase(new Paragraph("1", fontChina12));
 780             cell48.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 781             table.addCell(cell48);
 782             PdfPCell cell49 = new PdfPCell();
 783             cell49.setBorderWidth(1);
 784             cell49.setPhrase(new Paragraph("2", fontChina12));
 785             cell49.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 786             table.addCell(cell49);
 787             PdfPCell cell50 = new PdfPCell();
 788             cell50.setBorderWidth(1);
 789             cell50.setPhrase(new Paragraph("3", fontChina12));
 790             cell50.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 791             table.addCell(cell50);
 792             PdfPCell cell51 = new PdfPCell();
 793             cell51.setBorderWidth(1);
 794             cell51.setPhrase(new Paragraph("4", fontChina12));
 795             cell51.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 796             table.addCell(cell51);
 797             PdfPCell cell52 = new PdfPCell();
 798             cell52.setBorderWidth(1);
 799             cell52.setPhrase(new Paragraph("5", fontChina12));
 800             cell52.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 801             table.addCell(cell52);
 802             PdfPCell cell53 = new PdfPCell();
 803             cell53.setBorderWidth(1);
 804             cell53.setPhrase(new Paragraph("6", fontChina12));
 805             cell53.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 806             table.addCell(cell53);
 807             
 808             //合计
 809             PdfPCell cell54 = new PdfPCell();
 810             cell54.setBorderWidth(1);
 811             cell54.setPhrase(new Paragraph("合计", fontChina12));
 812             cell54.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 813             table.addCell(cell54);
 814             PdfPCell cell55 = new PdfPCell();
 815             cell55.setBorderWidth(1);
 816             cell55.setColspan(5);//跨5列
 817             cell55.setPhrase(new Paragraph("合计", fontChina12));
 818             cell55.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 819             table.addCell(cell55);
 820             
 821             //增值税价税合计
 822             PdfPCell cell56 = new PdfPCell();
 823             cell56.setBorderWidth(1);
 824             cell56.setPhrase(new Paragraph("增值税价税合计", fontChina12));
 825             cell56.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 826             table.addCell(cell56);
 827             PdfPCell cell57 = new PdfPCell();
 828             cell57.setBorderWidth(1);
 829             cell57.setColspan(5);//跨5列
 830             cell57.setPhrase(new Paragraph("增值税价税合计", fontChina12));
 831             cell57.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 832             table.addCell(cell57);
 833             
 834             //车辆信息
 835             PdfPCell cell58 = new PdfPCell();
 836             cell58.setBorderWidth(1);
 837             cell58.setPhrase(new Paragraph("车种", fontChina12));
 838             cell58.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 839             table.addCell(cell58);
 840             PdfPCell cell59 = new PdfPCell();
 841             cell59.setBorderWidth(1);
 842             cell59.setPhrase(new Paragraph("车种", fontChina12));
 843             cell59.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 844             table.addCell(cell59);
 845             
 846             PdfPCell cell60 = new PdfPCell();
 847             cell60.setBorderWidth(1);
 848             cell60.setPhrase(new Paragraph("车号", fontChina12));
 849             cell60.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 850             table.addCell(cell60);
 851             PdfPCell cell61 = new PdfPCell();
 852             cell61.setBorderWidth(1);
 853             cell61.setPhrase(new Paragraph("车号", fontChina12));
 854             cell61.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 855             table.addCell(cell61);
 856             
 857             PdfPCell cell62 = new PdfPCell();
 858             cell62.setBorderWidth(1);
 859             cell62.setPhrase(new Paragraph("车船吨位", fontChina12));
 860             cell62.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 861             table.addCell(cell62);
 862             PdfPCell cell63 = new PdfPCell();
 863             cell63.setBorderWidth(1);
 864             cell63.setPhrase(new Paragraph("车船吨位", fontChina12));
 865             cell63.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 866             table.addCell(cell63);
 867         
 868             //申请资料清单
 869             PdfPCell cell64 = new PdfPCell();
 870             cell64.setBorderWidth(1);
 871             cell64.setColspan(6);//跨六列
 872             cell64.setPhrase(new Paragraph("申请资料清单", fontChina12));
 873             cell64.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 874             cell64.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
 875             table.addCell(cell64);
 876             
 877             PdfPCell cell65 = new PdfPCell();
 878             cell65.setBorderWidth(1);
 879             cell65.setColspan(3);//跨3列
 880             cell65.setPhrase(new Paragraph("1、《税务登记证》或《临时税务登记证》副本、经办人合法身份证件及复印件()", fontChina12));
 881             cell65.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 882             table.addCell(cell65);
 883             PdfPCell cell66 = new PdfPCell();
 884             cell66.setBorderWidth(1);
 885             cell66.setColspan(3);//跨3列
 886             cell66.setPhrase(new Paragraph("2、承包、承租车辆、船舶营运的,应提供承包、承租合同复印件及出包、出租方车辆、船舶营运资质的有效证明原件及复印件()", fontChina12));
 887             cell66.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 888             table.addCell(cell66);
 889             
 890             PdfPCell cell67 = new PdfPCell();
 891             cell67.setBorderWidth(1);
 892             cell67.setColspan(3);//跨3列
 893             cell67.setPhrase(new Paragraph("3、承运人自有车辆、船舶及营运资质的有效证明原件及复印件()", fontChina12));
 894             cell67.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 895             table.addCell(cell67);
 896             PdfPCell cell68 = new PdfPCell();
 897             cell68.setBorderWidth(1);
 898             cell68.setColspan(3);//跨3列
 899             cell68.setPhrase(new Paragraph("4、承运人同货主签订的承运货物合同或者托运单、完工单等其它有效证明复印件()", fontChina12));
 900             cell68.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 901             table.addCell(cell68);
 902             
 903             //以下由主管国税机关填写
 904             PdfPCell cell69 = new PdfPCell();
 905             cell69.setBorderWidth(1);
 906             cell69.setColspan(6);//跨六列
 907             cell69.setPhrase(new Paragraph("以下由主管国税机关填写", fontChina12));
 908             cell69.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 909             cell69.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
 910             table.addCell(cell69);
 911             
 912             PdfPCell cell70 = new PdfPCell();
 913             cell70.setBorderWidth(1);
 914             cell70.setPhrase(new Paragraph("完税凭证号码", fontChina12));
 915             cell70.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 916             table.addCell(cell70);
 917             PdfPCell cell71 = new PdfPCell();
 918             cell71.setBorderWidth(1);
 919             cell71.setPhrase(new Paragraph("完税凭证号码", fontChina12));
 920             cell71.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 921             table.addCell(cell71);
 922             
 923             PdfPCell cell72 = new PdfPCell();
 924             cell72.setBorderWidth(1);
 925             cell72.setPhrase(new Paragraph("填开日期", fontChina12));
 926             cell72.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 927             table.addCell(cell72);
 928             PdfPCell cell73 = new PdfPCell();
 929             cell73.setBorderWidth(1);
 930             cell73.setPhrase(new Paragraph("填开日期", fontChina12));
 931             cell73.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 932             table.addCell(cell73);
 933             
 934             PdfPCell cell74 = new PdfPCell();
 935             cell74.setBorderWidth(1);
 936             cell74.setPhrase(new Paragraph("税款征收岗(签章)", fontChina12));
 937             cell74.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 938             table.addCell(cell74);
 939             PdfPCell cell75 = new PdfPCell();
 940             cell75.setBorderWidth(1);
 941             cell75.setPhrase(new Paragraph("税款征收岗(签章)", fontChina12));
 942             cell75.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 943             table.addCell(cell75);
 944             
 945             PdfPCell cell76 = new PdfPCell();
 946             cell76.setBorderWidth(1);
 947             cell76.setPhrase(new Paragraph("发票号码", fontChina12));
 948             cell76.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 949             table.addCell(cell76);
 950             PdfPCell cell77 = new PdfPCell();
 951             cell77.setBorderWidth(1);
 952             cell77.setColspan(2);//跨2列
 953             cell77.setPhrase(new Paragraph("发票号码", fontChina12));
 954             cell77.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 955             table.addCell(cell77);
 956             
 957             PdfPCell cell78 = new PdfPCell();
 958             cell78.setBorderWidth(1);
 959             cell78.setPhrase(new Paragraph("发票代码", fontChina12));
 960             cell78.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 961             table.addCell(cell78);
 962             PdfPCell cell79 = new PdfPCell();
 963             cell79.setBorderWidth(1);
 964             cell79.setColspan(2);//跨2列
 965             cell79.setPhrase(new Paragraph("发票代码", fontChina12));
 966             cell79.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 967             table.addCell(cell79);
 968             
 969             PdfPCell cell80 = new PdfPCell();
 970             cell80.setBorderWidth(1);
 971             cell80.setPhrase(new Paragraph("填开日期", fontChina12));
 972             cell80.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 973             table.addCell(cell80);
 974             PdfPCell cell81 = new PdfPCell();
 975             cell81.setBorderWidth(1);
 976             cell81.setColspan(2);//跨2列
 977             cell81.setPhrase(new Paragraph("填开日期", fontChina12));
 978             cell81.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 979             table.addCell(cell81);
 980             
 981             PdfPCell cell82 = new PdfPCell();
 982             cell82.setBorderWidth(1);
 983             cell82.setPhrase(new Paragraph("代开发票岗(签章)", fontChina12));
 984             cell82.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 985             table.addCell(cell82);
 986             PdfPCell cell83 = new PdfPCell();
 987             cell83.setBorderWidth(1);
 988             cell83.setColspan(2);//跨2列
 989             cell83.setPhrase(new Paragraph("代开发票岗(签章)", fontChina12));
 990             cell83.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 991             table.addCell(cell83);
 992             
 993             PdfPCell cell84 = new PdfPCell();
 994             cell84.setBorderWidth(1);
 995             cell84.setMinimumHeight(40);
 996             cell84.setPhrase(new Paragraph("备注", fontChina12));
 997             cell84.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
 998             table.addCell(cell84);    
 999             PdfPCell cell85 = new PdfPCell();
1000             cell85.setBorderWidth(1);
1001             cell85.setColspan(5);//跨5列
1002             cell85.setPhrase(new Paragraph("备注", fontChina12));
1003             cell85.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
1004             table.addCell(cell85);    
1005             
1006             document.add(table);
1007             
1008             //申请人(签章):
1009             Paragraph p1 = new Paragraph("申请人(签章):", fontChina12);
1010             p1.setAlignment(Element.ALIGN_RIGHT);
1011             p1.setIndentationRight(100);
1012             document.add(p1);
1013             
1014             //
1015             Paragraph p2 = new Paragraph("注:1.本表一式三份,税款征收岗、代开发票管理岗、纳税人各一份。", fontChina12);
1016             p2.setAlignment(Element.ALIGN_CENTER);
1017             document.add(p2);
1018             
1019             
1020             // 5:关闭文档
1021             document.close();
1022         } catch (FileNotFoundException e) {
1023             e.printStackTrace();
1024         } catch (DocumentException e) {
1025             e.printStackTrace();
1026         } catch (IOException e) {
1027             e.printStackTrace();
1028         }
1029     }
1030 }
posted @ 2014-05-31 10:59  yshy  阅读(3263)  评论(0编辑  收藏  举报