spire.office for java 3.9.4现已发布。此次更新的版本拥有许多新功能,例如,spire.doc for java支持比较两个word文档和清除单元格背景;spire.pdf for java支持将svg转换到pdf;spire.xls for java支持将excel转换到tiff;spire.presentation for java支持更新ppt文档中的video视频数据;spire.barcode for java支持设置条码顶部文本的排列方式。与此同时,一些在加载、操作和转换word、excel、pdf和presentation文档及扫描条形码时出现的问题也得以成功解决。
获取spire.office for java 3.9.4,请点击:https://www.e-iceblue.cn/downloads/spire-office-java.html
spire.doc for java
新功能:
- 支持比较两个word文档
document doc1 = new document();
doc1.loadfromfile(inputfile_1);
document doc2 = new document();
doc2.loadfromfile(inputfile_2);
doc1.compare(doc2, "e-iceblue");
doc1.savetofile(outputfile);
tablecell.getcellformat().clearbackground();
doc.savetoimages(pageindex, pagecount, imagetype.bitmap, dpix, dpiy);
优化:
- 优化了加载word文档的时长
- 优化了转换word到pdf的时长
问题修复:
- 修复了转换html到pdf,多出方框的问题
- 修复了转换word到pdf,横线丢失的问题
- 修复了转换word到pdf,内容不正确的问题
- 修复了设置文本框背景色为无填充不生效的问题
- 修复了保存到.doc,表格被分页的问题
- 修复了图表交替插入题注,交叉引用位置不正确的问题
- 修复了加载文档程序抛异常“illegalargumentexception”
- 修复了添加图片到页眉,生成的.docx用微软word2007版本打开提示内容有错误的问题
- 修复了保存文档,修订不正确的问题
- 修复了转换word到图片,内容格式不正确的问题
- 修复了获取文档页数时程序抛异常arrayindexoutofboundsexception的问题。
- 修复了移除分节符保存文档时程序抛异常specified method is not supported的问题。
- 修复了插入目录后进行更新目录域时程序抛异常stackoverflowerror的问题。
- 修复了加载文档时抛出异常no have this value 3的问题。
- 修复了插入目录后进行更新目录域时程序抛异常index is less than 0 or more than or equal to the list count的问题。
- 修复了转换doc到图片程序抛出异常com.spire.doc.packages.sprezb: no have this value 4的问题。
- 修复了转换word到pdf时heading1域的值不正确的问题。
spire.pdf for java
新功能:
- 支持转换svg到pdf。
pdfdocument doc = new pdfdocument();
doc.loadfromsvg(inputfile_svg);
doc.savetofile(outputfile);
pdfdocument doc1 = new pdfdocument();
doc1.loadfromsvg(inputfile_svg);
pdfdocument doc2 = new pdfdocument();
doc2.loadfromfile(inputfile_pdf);
doc2.getpages().get(0).getcanvas().drawtemplate(doc1.getpages().get(0).createtemplate(), new point2d.float(10,10), new dimension(100,100) );
doc2.savetofile(outputfile, fileformat.pdf);
doc1.close();
doc2.close();
pdfdocument pdf = new pdfdocument();
pdf.loadfromfile(inputfile);
pdf.getconvertoptions().setconverttowordusingflow(true);
pdf.savetofile(outputfile_doc, fileformat.doc);
pdfdocument pdf = new pdfdocument();
pdf.loadfromfile(inputfile);
pdf.savetofile(outputpath, fileformat.xlsx);
问题修复:
- 修复了绘制阿拉伯字形不正确的问题。
- 修复了提取文本乱码的问题。
- 修复了ubuntu系统上转换pdf到图片,内容不正确的问题。
- 修复了转换pdf到图片,出现多余虚线的问题。
- 修复了转换pdf到图片,图章丢失的问题。
spire.xls for java
新功能:
- 新增方法workbook.savetotiff(string filename)支持转换excel到一个tiff文件。
- 转换excel到image时支持了设置dpi。
workbook.getconvertersetting().setxdpi(300);
workbook.getconvertersetting().setydpi(300);
worksheet sheet;
for (int i = 0; i < wb.getworksheets().size(); i ) {
sheet = wb.getworksheets().get(i);
sheet.savetoimage(outputfile i ".png");
}
问题修复:
- 优化了转换excel到html的时间性能。
- 修复了转换excel到pdf时抛出异常numberformatexception的问题。
- 修复了转换excel到图片时抛异常size of image is too large的问题。
- 修复了ubuntu上转换excel到图片抛出异常java.lang.illegalstateexception: cannot find a required cmap table.的问题。
- 修复了转换excel到图片时图片内容不清晰的问题。
- 修复了转换excel到pdf时数字格式不正确的问题。
- 修复了获取xls文档属性值失败的问题。
- 修复了在xls文档里插入背景图片不显示的问题。
- 修复了转换excel到html数字值不正确的问题。
spire.presentation for java
新功能:
- 支持更新ppt文档中的video视频数据。
file file = new file("videopath");
fileinputstream fileinputstream = new fileinputstream(file);
byte[] data = new byte[(int)file.length()];
fileinputstream.read(data);
videocollection videos = presentation.getvideos();
videodata videodata = videos.append(data);
ivideo ivideo = (ivideo) presentation.getslides().get(0).getshapes().get(0);
ivideo.setembeddedvideodata(videodata);
for (int i = 0; i < presentation.getslides().getcount(); i ) {
islide slide = presentation.getslides().get(i);
for (int j = 0; j < slide.getshapes().getcount(); j ) {
ishape shape = slide.getshapes().get(j);
if (shape instanceof iaudio) {
string audiopartname = ((iaudio) shape).getdata().getpartname();
}
if (shape instanceof ivideo) {
string videopartname = ((ivideo) shape).getembeddedvideodata().getpartname();
}
}
for (int i = 0; i < slide.gettimeline().getmainsequence().getcount(); i ) {
animationeffect animationeffect = slide.gettimeline().getmainsequence().get(i);
animationamounttype amount = animationeffect.getamount();
}
presentation presentation = new presentation();
presentation.loadfromfile("data/animation.pptx");
for (int c = 0; c < presentation.getslides().getcount(); c ) {
islide slide = presentation.getslides().get(c);
for (int i = 0; i < slide.gettimeline().getmainsequence().getcount(); i ) {
animationeffect animationeffect = slide.gettimeline().getmainsequence().get(i);
//预设类型,比如entrance,emphasis,exit,path
string presetclasstype = animationeffect.getpresetclasstype().getname();
//获取动画效果类型
animationeffecttype animationeffecttype= animationeffect.getanimationeffecttype();
//获取目标shape
shape shape = animationeffect.getshapetarget();
//获取动画效果子类型
string subtype = animationeffect.getsubtype().getname();
//获取color
color color = animationeffect.getcolor();
//当动画效果类型为faded_zoom时,获取vanishing point(消失点)
if (animationeffecttype.equals(animationeffecttype.faded_zoom)) {
string vanishingpointname = animationeffect.getvanishingpoint().getname();
}
//获取wave动画效果
if (animationeffecttype.equals(animationeffecttype.wave)) {
textanimationcollection textanimations = slide.gettimeline().gettextanimations();
if (textanimations.size() > 0) {
for (int j = 0; j < textanimations.size(); j ) {
paragraphbuildtype buildtype = textanimations.get(j).getparagraphbuildtype();
}
}
}
}
}
优化:
- 优化了生成的ppt文档大小。
问题修复:
- 修复了ppt转pdf,线条位置不正确的问题。
- 修复了设置文本下划线不起作用的问题。
- 修复了创建散点直线类型的图表含有标记的问题。
- 修复了保存文档抛"nullreferenceexception"的问题。
- 修复了设置动画期间时间不生效的问题。
- 修复了ppt转pdf抛"nullpointerexception"的问题。
- 修复了保存文档和调整幻灯片顺序抛错误"unknown char: 林"的问题。
- 修复了获取到的动画持续时间不正确的问题。
- 修复了获取动画运动轨迹抛"nullpointerexception"的问题。
- 修复了无法获取到ppt动画的问题。
- 修复了插入html文本到ppt,br标签不生效的问题。
- 修复了无法获取到ppt动画的subtype属性的问题。
- 修复了转换.pptx to pdf程序抛"nullpointerexception "的问题。
- 修复了了转换.pptx to pdf图表坐标轴内容格式不正确的问题。
spire.barcode for java
新功能:
- 支持设置条码顶部文本的排列方式。
int width = 399;
int height = 159;
barcodesettings bs = new barcodesettings();
bs.settype(barcodetype.upca);
bs.setunit(graphicsunit.pixel);
bs.setwidenarrowratio(0.5f);
bs.settextfont(new font("arial", font.plain,20 ));
string data = "602318275035";
bs.setdata(data);
bs.setdata2d(data);
bs.setshowtextonbottom(true);
bs.settoptext(data);
bs.setshowtoptext(true);
bs.settextalignment(stringalignment.center);
bs.settoptextaligment(stringalignment.center);
bs.settoptextfont(new font("arial", font.plain, 20));
bs.setautoresize(false);
bs.setx(3.0f);
bs.setbarheight(height * 0.6f);
bs.setimageheight(height);
bs.setimagewidth(width);
barcodegenerator barcodegenerator = new barcodegenerator(bs);
bufferedimage bufferedimage = barcodegenerator.generateimage();
imageio.write(bufferedimage, "png", new file("result.png"));
barsetting.setbottomtext("ean");
barsetting.setbottomtextfont(new font("fangsong", font.bold, 25));
barsetting.setbottomtextcolor(color.black);
barsetting.setshowbottomtext(true);
barsetting.setbottomtextalignment(stringalignment.center);
问题修复:
- 修复了扫描条形码得到的数据不正确的问题。
- 修复了扫描条形码失败的问题。
- 修复了扫描条形码程序抛“nullpointerexception”的问题。
- 修复了添加自定义文本不生效的问题。
- 修复了扫描含特殊字符的qr码,得到的数据错误的问题。