spire.pdf for java 2.9.1已正式发布。该版本支持向网格添加图片以及填充xfadatetimefield。此外,也修复了将pdf转换为word、提取中文文本和填充文本框时出现的一些问题。新功能及问题修复详情,请参见以下内容。
新功能:
- 支持添加图片到grid
pdfdocument doc = new pdfdocument();
doc.loadfromfile(inputfile);
pdfpagebase page = doc.getpages().get(0);
pdfgrid grid = new pdfgrid();
pdfgridrow row = grid.getrows().add();
grid.getcolumns().add(2);
grid.getcolumns().get(0).setwidth(120);
grid.getcolumns().get(1).setwidth(300);
dimension2d imagesize = new dimension();
imagesize.setsize(70,70);
float lr = (grid.getcolumns().get(0).getwidth()-(float) imagesize.getwidth())/2;
pdfgridcellcontentlist list = new pdfgridcellcontentlist();
pdfgridcellcontent textandstyle = new pdfgridcellcontent();
textandstyle.setimage(pdfimage.fromfile("./data/imgfiles/e-iceblue logo.png"));
textandstyle.setimagesize(imagesize);
list.getlist().add(textandstyle);
row.getcells().get(0).setvalue(list);
grid.draw(page, new point2d.double(50, 330));
doc.savetofile(outputfile);
pdfdocument doc = new pdfdocument();
doc.loadfromfile(inputfile);
stringbuilder sb = new stringbuilder();
pdfformwidget formwidget = (pdfformwidget) doc.getform();
list xfafields = formwidget.getxfaform().getxfafields();
for (int i = 0; i < xfafields.size(); i ) {
if (xfafields.get(i) instanceof xfadatetimefield) {
xfadatetimefield xf = (xfadatetimefield) xfafields.get(i);
sb.append( "xfafields" i xf.getvalue() "\r\n");
xf.setvalue("gray1");
sb.append("xfafields" i xf.getvalue() "\r\n");
sb.append( "\r\n");
}
}
filewriter filewriter = new filewriter(outputfile_t);
filewriter.write(sb.tostring());
filewriter.flush();
filewriter.close();
doc.savetofile(outputfile);
问题修复:
- 修复了用相同的坐标绘制图章和文本框域时,位置不一致的问题
- 修复了pdf 转 word,内容有被遮盖的问题
- 修复了提取的中文文本不正确的问题
- 修复了pdf 转 word,内容重叠的问题
- 修复了填充textboxfield域失败的问题
获取spire.pdf for java 2.9.1,请点击: