今天我们正式发布了spire.office for java 3.5.0,该版本带来了一些不错的新功能,例如,spire.pdf支持数字签名时添加时间戳,支持各种形状的注释框到pdf;spire.presetation 支持获取形状中文本输入区域的最大宽度。具体更新内容如下。
spire.doc for java
问题修复:
- 修复了加载文档抛出的unknown format异常。
- 修复了加载文档抛出的indexoutofboundsexception异常。
- 修复了加载文档抛出的nullpointerexception异常。
- 修复了加载文档抛出的illegalstateexception异常。
- 修复了加载文档抛出的arrayindexoutofboundsexception异常。
- 修复了加载文档抛出的no have this value 5异常。
- 修复了进行更新目录域报错input string was not in the correct format。
- 修复了进行更新目录域报错stackoverflowerror。
- 修复了转换html到word文档格式不正确的问题。
- 修复了移除分节符保存文档抛出的nullpointerexception异常。
- 修复了公式域更新不正确的问题。
spire.presentation for java
新功能:
- 支持获取形状中文本输入区域的最大宽度。
iautoshape shape = (iautoshape) ppt.getslides().get(0).getshapes().get(0);
float maxwidth = shape.gettextframe().getmaxwidth();
iautoshape shape = (iautoshape) ppt.getslides().get(0).getshapes().get(0);
double x = shape.gettextframe().getstartlocationatmaxwidth().getx();
double y = shape.gettextframe().getstartlocationatmaxwidth().gety();
问题修复:
- 修复了在centos中转换pptx文档到图片,白色文本变成黑色的问题。
- 修复了”getcolor()”方法获取到的表格单元格文本颜色错误的问题。
- 修复了“shape.istextbox()”方法返回值不正确的问题。
- 修复了加载文档时抛异常“未将对象引用设置到对象的实例”的问题。
- 修复了设置图表的数据表边框后未正确显示的问题。
spire.pdf for java
新功能:
- 支持pdf签名添加时间戳。
//配置时间戳服务器
string url = "https://freetsa.org/tsr";
signature.configuretimestamp(url);
signature.addshowconfiguretext(signatureconfiguretext.contact_info);//显示contact_info(默认显示所有)
signature.removeshowconfiguretext(signatureconfiguretext.contact_info);//不显示contact_info
signature.setshowconfiguretext(enumset.of(signatureconfiguretext.contact_info));//只显示contact_info
pdfdocument pdf = new pdfdocument();
pdfpagebase page = pdf.getpages().add();
//箭头
string text1 = "this is arrow annotation";
pdffont font = new pdffont(pdffontfamily.helvetica, 20);
pdfsolidbrush brush1 = new pdfsolidbrush(new pdfrgbcolor(color.blue));
pdfstringformat leftalignment = new pdfstringformat(pdftextalignment.left, pdfverticalalignment.middle);
page.getcanvas().drawstring(text1, font, brush1, 50, 50, leftalignment);
dimension2d dimension = font.measurestring(text1);
rectangle2d.float bounds = new rectangle2d.float(50, 50, (float) dimension.getwidth(), (float) dimension.getheight());
int[] linepoints = new int[]{92, (int) (page.getsize().getheight() - bounds.gety() - 60),
(int) (92 bounds.getwidth()), (int) (page.getsize().getheight() - bounds.gety() - 60)};
pdflineannotation annotation1 = new pdflineannotation(linepoints, "linearrow annotation test");
annotation1.setbeginlinestyle(pdflineendingstyle.openarrow);
annotation1.setendlinestyle(pdflineendingstyle.openarrow);
annotation1.setbackcolor(new pdfrgbcolor(color.red));
annotation1.setcaptiontype(pdflinecaptiontype.inline);
annotation1.setlinecaption(true);
((pdfnewpage) page).getannotations().add(annotation1);
//云朵
string text2 = "this is cloud annotation";
pdfbrush brush2 = pdfbrushes.getblue();
page.getcanvas().drawstring(text2, font, brush2, 50, 200);
point2d point2d[] = new point2d[]{
new point2d.float(30, 200),
new point2d.float(300, 180),
new point2d.float(300, 250),
new point2d.float(30, 220),
new point2d.float(30, 200)
};
pdfpolygonannotation annotation2 = new pdfpolygonannotation(page, point2d);
annotation2.settext("polygoncloud annotation test");
annotation2.setauthor("e-iceblue");
annotation2.setsubject("test");
annotation2.setmodifieddate(new date());
annotation2.setbordereffect(pdfbordereffect.big_cloud);
annotation2.setlocation(new point2d.float(190, 230));
annotation2.setcolor(new pdfrgbcolor(color.gray));
((pdfnewpage) page).getannotations().add(annotation2);
//椭圆
string text3 = "this is circle annotation";
pdfbrush brush3 = pdfbrushes.getblue();
dimension2d dimension2d = font.measurestring(text3);
dimension2d.setsize(dimension2d.getwidth() 35, dimension2d.getheight() 20);
page.getcanvas().drawstring(text3, font, brush3, 50, 300);
rectangle2d.float annotationbounds1 = new rectangle2d.float();
annotationbounds1.setframe(new point2d.float(36, (float) 290), dimension2d);
pdfsquareandcircleannotation annotation3 = new pdfsquareandcircleannotation(annotationbounds1);
annotation3.setsubtype(pdfsquareandcircleannotationtype.circle);
float[] f1 = {0.5f, 0.5f, 0.5f, 0.5f};
annotation3.setrectangulardifferencearray(f1);
annotation3.settext("circle annotation test");
annotation3.setcolor(new pdfrgbcolor(color.red));
annotation3.setmodifieddate(new date());
annotation3.setname("*****");
lineborder border1 = new lineborder();
border1.setborderwidth(2);
annotation3.setlineborder(border1);
((pdfnewpage) page).getannotations().add(annotation3);
//矩形
string text4 = "this is square annotation";
pdfbrush brush4 = pdfbrushes.getblue();
dimension2d dimension4 = font.measurestring(text4);
dimension2d.setsize(dimension2d.getwidth() 80, dimension2d.getheight() 20);
page.getcanvas().drawstring(text4, font, brush4, 50, 400);
rectangle2d.float annotationbounds2 = new rectangle2d.float();
annotationbounds2.setframe(new point2d.float(30, (float) 400), dimension4);
pdfsquareandcircleannotation annotation4 = new pdfsquareandcircleannotation(annotationbounds2);
annotation4.setsubtype(pdfsquareandcircleannotationtype.square);
float[] f2 = {0.5f, 0.5f, 0.5f, 0.5f};
annotation4.setrectangulardifferencearray(f2);
annotation4.settext("square annotation test");
annotation4.setcolor(new pdfrgbcolor(color.red));
annotation4.setmodifieddate(new date());
annotation4.setname("*****");
lineborder border2 = new lineborder();
border2.setborderwidth(2);
annotation4.setlineborder(border2);
((pdfnewpage) page).getannotations().add(annotation4);
//连接线
string text5 = "this is connected lines annotation";
pdfbrush brush5 = pdfbrushes.getblue();
page.getcanvas().drawstring(text5, font, brush5, 50, 465);
point2d pointzd[] = new point2d[]{
new point2d.float(30, 470),
new point2d.float(300, 450),
new point2d.float(300, 520),
new point2d.float(30, 490),
new point2d.float(30, 470)
};
pdfpolygonannotation annotation5 = new pdfpolygonannotation(page, pointzd);
annotation5.settext("connected lines annotation test");
annotation5.setauthor("冰蓝");
annotation5.setsubject("test");
annotation5.setmodifieddate(new date());
annotation5.setbordereffect(pdfbordereffect.none);
annotation5.setlocation(new point2d.float(190, 230));
annotation5.setcolor(new pdfrgbcolor(color.gray));
((pdfnewpage) page).getannotations().add(annotation5);
pdf.savetofile("output/annotation.pdf");
for (pdfpagebase page : (iterable) doc.getpages()) {
content.append(page.extracttext(true,true,true));
}
问题修复:
- 修复了提取文本时空格与源文档不一致的问题。
- 修复了设置“setcertificated(true)”不生效的问题。
- 修复了提出表格文本时存在多余的空行的问题。
- 修复了调用“dispose”方法后,“file.delete”方法无法删除文件的问题。
- 优化了pdf转换到图片耗时较长的问题。
获取spire.office for java 3.5.0,请点击: