iText 生成 PDF(java)
更新时间:2023-11-23 17:22:01 阅读量: 教育文库 文档下载
- itest智能测评云平台推荐度:
- 相关推荐
iText 生成 PDF (java)
标签: itextpdfit 分类: java技术文档
public class BL { ***
// private String rgtno = \
private SSRS ssrsRgtno = new SSRS();// rgtno 赔案号,grpcontno 团体保单号,grpname // 投保单位,endcasedate 结案日期
private SSRS ssrsCustomerno = new SSRS();// customerno客户号
private SSRS ssrsIdno = new SSRS();// idno 证件号,bankcode 银行编码,bankaccno // 账号,accname 户名
private SSRS ssrsOpt = new SSRS();// 门诊医疗费用理算信息: private SSRS ssrsHos = new SSRS();// 住院医疗费用理算信息: private SSRS ssrsBirth = new SSRS();// 生育医疗费用理算信息:
private SSRS sumSsrsOpt = new SSRS();// 门诊医疗费用理算信息:总计 private SSRS sumSsrsHos = new SSRS();// 住院医疗费用理算信息:总计 private SSRS sumSsrsBirth = new SSRS();// 生育医疗费用理算信息:总计
public boolean batchPrint() throws DocumentException, IOException {
String rgtno = \String rgtno2 = \String rgtno3 = \
ArrayList rgtnoList = new ArrayList(); rgtnoList.add(rgtno); rgtnoList.add(rgtno2); rgtnoList.add(rgtno3);
Document document = new Document(PageSize.A4, 10, 10, 60, 20);// 参数:第一个是页面大小;接下来是左右上下边距; try {
// // 生成名为xxx的文档
PdfWriter.getInstance(document, new FileOutputStream( \
BaseFont bfChinese = BaseFont.createFont(\
\
Color colorGray = new Color(217, 217, 217); Color colorBlack = new Color(0, 0, 0);
Font titleFont = new Font(bfChinese, 21, Font.BOLD, colorBlack); Font infoFont = new Font(bfChinese, 11, Font.NORMAL, colorBlack); Font infoLittleNormal = new Font(bfChinese, 10, Font.NORMAL, colorBlack);
Font infoLittleBold = new Font(bfChinese, 10, Font.BOLD, colorBlack);
document.open();
for (int i = 0; i < rgtnoList.size(); i++) {
String rgtn22o =rgtnoList.get(i).toString(); // 查询数据
selectData(rgtn22o);
// 打开文档,将要写入内容 document.newPage();
// 插入图片:可以是绝对路径,也可以是URL // String path = \
String path = getClass().getProtectionDomain().getCodeSource().getLocation().getPath();
if (path.indexOf( \
path = path.substring(0, path.indexOf( \}
path = path + \
// String path = \printImage(document, path);
// 打印PDF头部信息
printHead(document, titleFont, infoFont);
// 打印空白表格
printBlank(document, titleFont);
printInfoTable(document, infoFont);
// 门诊医疗费用理算信息
String strOpt = \门诊医疗费用理算信息\门诊医疗费用理算信息,表头
printInfoTable(document, strOpt, infoLittleBold, infoLittleNormal, colorGray, ssrsOpt, sumSsrsOpt);
// 住院医疗费用理算信息
String strHos = \住院医疗费用理算信息\门诊医疗费用理算信息,表头 printInfoTable(document, strHos, infoLittleBold, infoLittleNormal, colorGray, ssrsHos, sumSsrsHos);
// 生育医疗费用理算信息
String strBirth = \生育医疗费用理算信息\门诊医疗费用理算信息,表头 printInfoTable(document, strBirth, infoLittleBold, infoLittleNormal, colorGray, ssrsBirth, sumSsrsBirth);
// 打印PDF结尾部分
printEndInfoTable(document, infoFont, colorGray); }
} catch (DocumentException de) { System.err.println(de.getMessage()); } catch (IOException ioe) {
System.err.println(ioe.getMessage()); }
document.close(); return true; }
public void setAlignment(PdfPCell pdfPCell, int verticalAlign, int horizontalAlign) {
if (verticalAlign == Element.ALIGN_MIDDLE) {
pdfPCell.setVerticalAlignment(Element.ALIGN_MIDDLE);// 垂直居中 } else if (verticalAlign == Element.ALIGN_TOP) {
pdfPCell.setVerticalAlignment(Element.ALIGN_TOP);// 垂直上居中 } else if (verticalAlign == Element.ALIGN_BOTTOM) {
pdfPCell.setVerticalAlignment(Element.ALIGN_BOTTOM);// 垂直下居中 }
if (horizontalAlign == Element.ALIGN_CENTER) {
pdfPCell.setHorizontalAlignment(Element.ALIGN_CENTER);// 水平居中 } else if (horizontalAlign == Element.ALIGN_LEFT) {
pdfPCell.setHorizontalAlignment(Element.ALIGN_LEFT);// 水平左居中 } else if (horizontalAlign == Element.ALIGN_RIGHT) {
pdfPCell.setHorizontalAlignment(Element.ALIGN_RIGHT);// 水平右居中
} }
public void setOptInfoStyle(PdfPCell pdfPCell) {
setDisableBorder(pdfPCell, 0, 0, 4, 8);// 上下边框显示,左右边框不显示。 setCellPadding(pdfPCell, 3, 4, 4, 4);// 设置单元格距离 }
public void setCellPadding(PdfPCell pdfPCell, int top, int bottom, int left, int right) {
pdfPCell.setPaddingTop(top);
pdfPCell.setPaddingBottom(bottom); pdfPCell.setPaddingLeft(left); pdfPCell.setPaddingRight(right); }
public void setDisableBorder(PdfPCell pdfPCell, int top, int bottom, int left, int right) {
// 参数只能为1248,分别代表上下左右 if (top != 0) {
pdfPCell.disableBorderSide(top);// 不显示上边框 }
if (bottom != 0) {
pdfPCell.disableBorderSide(bottom);// 不显示下边框 }
if (left != 0) {
pdfPCell.disableBorderSide(left);// 不显示左边框 }
if (right != 0) {
pdfPCell.disableBorderSide(right);// 不显示右边框 } }
public void printBasicInfo(PdfPTable pdfPTable, Font infoFont, String strCellBI11, String strCellBI12, String strCellBI21, String strCellBI22, String strCellBI31, String strCellBI32, String strCellBI41, String strCellBI42) {
PdfPCell cellBasicInfo11 = new PdfPCell(new Phrase(strCellBI11, infoFont));
cellBasicInfo11.setVerticalAlignment(Element.ALIGN_LEFT);
cellBasicInfo11.setBorder(Rectangle.NO_BORDER); cellBasicInfo11.setPaddingTop(6); pdfPTable.addCell(cellBasicInfo11);
PdfPCell cellBasicInfo12 = new PdfPCell(new Phrase(strCellBI12, infoFont));
cellBasicInfo12.setVerticalAlignment(Element.ALIGN_LEFT); cellBasicInfo12.setBorder(Rectangle.NO_BORDER); cellBasicInfo12.setPaddingTop(6); pdfPTable.addCell(cellBasicInfo12);
PdfPCell cellBasicInfo21 = new PdfPCell(new Phrase(strCellBI21, infoFont));
cellBasicInfo21.setVerticalAlignment(Element.ALIGN_LEFT); cellBasicInfo21.setBorder(Rectangle.NO_BORDER); cellBasicInfo21.setPaddingTop(3); pdfPTable.addCell(cellBasicInfo21);
PdfPCell cellBasicInfo22 = new PdfPCell(new Phrase(strCellBI22, infoFont));
cellBasicInfo22.setVerticalAlignment(Element.ALIGN_LEFT); cellBasicInfo22.setBorder(Rectangle.NO_BORDER); cellBasicInfo22.setPaddingTop(3); pdfPTable.addCell(cellBasicInfo22);
PdfPCell cellBasicInfo31 = new PdfPCell(new Phrase(strCellBI31, infoFont));
cellBasicInfo31.setVerticalAlignment(Element.ALIGN_LEFT); cellBasicInfo31.setBorder(Rectangle.NO_BORDER); cellBasicInfo31.setPaddingTop(3); pdfPTable.addCell(cellBasicInfo31);
PdfPCell cellBasicInfo32 = new PdfPCell(new Phrase(strCellBI32, infoFont));
cellBasicInfo32.setVerticalAlignment(Element.ALIGN_LEFT); cellBasicInfo32.setBorder(Rectangle.NO_BORDER); cellBasicInfo32.setPaddingTop(3); pdfPTable.addCell(cellBasicInfo32);
PdfPCell cellBasicInfo41 = new PdfPCell(new Phrase(strCellBI41, infoFont));
cellBasicInfo41.setVerticalAlignment(Element.ALIGN_LEFT); cellBasicInfo41.setBorder(Rectangle.NO_BORDER); cellBasicInfo41.setPaddingTop(3);
正在阅读:
iText 生成 PDF(java)11-23
查理芒格:生活不仅仅是精明地积累财富(深度好文)(DOC)09-27
安全生产10月稿件05-23
部编版(统编版)小学语文 二年级下册教学计划2020.205-08
陈代明介绍09-14
房地产开发商名录11-30
XX工程基础施工环境保护措施XG05-18
卫星通信中的常见问题03-05
阿伦·艾弗森经典语录02-06
- exercise2
- 铅锌矿详查地质设计 - 图文
- 厨余垃圾、餐厨垃圾堆肥系统设计方案
- 陈明珠开题报告
- 化工原理精选例题
- 政府形象宣传册营销案例
- 小学一至三年级语文阅读专项练习题
- 2014.民诉 期末考试 复习题
- 巅峰智业 - 做好顶层设计对建设城市的重要意义
- (三起)冀教版三年级英语上册Unit4 Lesson24练习题及答案
- 2017年实心轮胎现状及发展趋势分析(目录)
- 基于GIS的农用地定级技术研究定稿
- 2017-2022年中国医疗保健市场调查与市场前景预测报告(目录) - 图文
- 作业
- OFDM技术仿真(MATLAB代码) - 图文
- Android工程师笔试题及答案
- 生命密码联合密码
- 空间地上权若干法律问题探究
- 江苏学业水平测试《机械基础》模拟试题
- 选课走班实施方案
- 生成
- iText
- java
- 第三章 教育目的 —我们需要怎样的教育
- 人教版八年级物理上册第3章 物态变化 单元测试题-精编
- 工程招投标及合同管理试题库1
- 会计考试试卷
- 2013年高考语文拓展阅读精选:喜欢还是不喜欢,才是根本
- 资产管理合同完整模板
- 徐州 素质教育概论 - 考试及答案 4月10考试 得分 88分
- NSAC全国标准化考试联盟认证试题flashcs3-2
- 英语阅读教程2--课文翻译
- 2015秋会计基础复习题
- 2016年山东政法干警考试行测真题及答案解析(本科类) - 图文
- 近三年党建工作总结
- C语言编写动态进度条
- 泄密事件报告和查处规定
- 《税法》期末考试题 - 所得税(附答案)
- 鸿泰物业员工满意度提升方案
- 骆驼祥子阅读题及答案
- 2009-2010年宏经试卷
- 《斑羚飞渡》阅读指导教案
- 中级练习题试卷3