Java导出pdf⽂件数据
提⽰:导出pdf⽂件,需要3个jar包iText-2.1.5.jar,iTextAsian.jar,iText-rtf-2.1.4.jar。
public boolean outputPdfJhsy(EntityBean data) {
try {
String pdfpath = ("LEAP/NSESTModule/WRModule/nsjhsyzm.pdf").getAbsolutePath(); //从eclip⽂件夹中得到pdf模版路径 String imgpath = ("LEAP/NSESTModule/WRModule/image/weiji.gif").getAbsolutePath(); //右下⾓盖章图⽚PdfReader reader = new PdfReader(pdfpath);
//创建输出⽬录
String pdfSavePath = Path("default")+"nstpdf/";
红包的英语
<(pdfSavePath).mkdir();
String filename = Instance().GetUUID()+".pdf";
pdfSavePath = pdfSavePath+filename;
PdfStamper stamp = new PdfStamper(reader, new FileOutputStream(pdfSavePath));
// 拿到第⼀页的上部内容部分
PdfContentByte over = OverContent(1);
//获取表单域(⽤Adobe Acrobat Pro⼯具)
AcroFields form = AcroFields();
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy年MM⽉dd⽇");
EntityBean bean = data;
try {
form.tField("busino", String("busino"));
中班数学公开课form.tField("jsbm", String("jsbm"));
form.tField("wname",String("wname"));
form.tField("wsfz",String("wsfz"));
form.tField("mname",String("mname"));
form.tField("msfz",String("msfz"));
form.tField("whjd",String("whjd"));
form.tField("wxjzd",String("wxjzd"));
form.tField("hyzk",String("hyzk"));
form.tField("jsqk",String("jsqk"));
form.tField("zncount",String("zncount"));
form.tField("znqk",String("znqk"));
form.tField("slrq",sdf2.format( sdf.String("slrq")) ) );
form.tField("wfjhsyzc",String("wfjhsyzc"));
form.tField("qtsm",String("qtsm"));
拆分表格好看古言form.tField("wname2",String("wname2"));
form.tField("wsfz2",String("wsfz2"));
form.tField("zmlxname", String("zmlxname"));
form.tField("jbr",String("jbr"));
form.tField("lxdh",String("lxdh"));
form.tField("sprq",String("sprq"));
} catch (Exception e) {
e.printStackTrace();
}
stamp.tFormFlattening(true); // 这句不能少
//创建⼀个image对象
Image image = Instance(imgpath);
//设置image对象的输出位置pa.getAsNumber(pa.size()-1).floatValue() 是该页pdf坐标轴的y轴的最⼤值
image.tAbsolutePosition(398,170);
image.scalePercent(70);
over.addImage(image);
over.stroke();
stamp.clo();
英文致谢
} catch (FileNotFoundException e) {
e.printStackTrace();
儿童血常规return fal;
西游记一共多少回} catch (DocumentException e) {
新课程学习e.printStackTrace();
return fal;
} catch (IOException e) {
e.printStackTrace();
return fal;
} finally {
}
return true;
}