Spire.Office for Java 11.5.0 已正式发布。本版本中,Spire.PDF for Java 新增支持 PDF 转换进度回调功能;Spire.Doc for Java 新增支持脚注/尾注计数以及字体嵌入选项;Spire.Presentation for Java 新增支持图片压缩功能。此外,本版本还成功修复了多个问题。更多详情如下。
获取 Spire.Office for Java 11.5.0,请点击:
https://www.e-iceblue.cn/Downloads/Spire-Office-JAVA.html
Spire.Doc for Java
新功能:
- 支持获取脚注或尾注的编号。
- 支持“仅嵌入文档使用的字符”设置。
Document doc = new Document();
doc.loadFromFile(inputFile);
StringBuilder sb = new StringBuilder();
for (int n = 0; n < doc.getSections().getCount(); n++) {
Section s = doc.getSections().get(n);
for (int i = 0; i < s.getParagraphs().getCount(); i++) {
Paragraph para = s.getParagraphs().get(i);
for (int j = 0, cnt = para.getChildObjects().getCount(); j < cnt; j++) {
ParagraphBase pBase = (ParagraphBase) para.getChildObjects().get(j);
if (pBase instanceof Footnote) {
Footnote fn = (Footnote) pBase;
if (fn.getFootnoteType() == FootnoteType.Footnote) {
StringBuilder fnText = new StringBuilder();
for (int k = 0; k < fn.getTextBody().getParagraphs().getCount(); k++) {
fnText.append(fn.getTextBody().getParagraphs().get(k).getText());
}
sb.append("Footnote:"+ fnText.toString() + "\nFootnoteID:" + fn.getId() + "\n");
}
if (fn.getFootnoteType() == FootnoteType.Endnote) {
StringBuilder enText = new StringBuilder();
for (int k = 0; k < fn.getTextBody().getParagraphs().getCount(); k++) {
enText.append(fn.getTextBody().getParagraphs().get(k).getText());
}
sb.append("Endnote:"+ enText.toString() + "\nEndnoteID:" + fn.getId() + "\n");
}
}
}
}
}
doc.setEmbedFontsInFile(true);
doc.setSaveSubsetFonts(true);
问题修复:
- 修复了 Word 转 PDF 效果不一致的问题。
- 修复了 Word 转 PDF 图片模糊的问题。
Spire.PDF for Java
新功能:
- 新增 PDF 文档转换进度回调支持。
class CustomProgressNotifier implements IProgressNotifier {
StringBuilder str = new StringBuilder();
private String outputFile;
public CustomProgressNotifier(String outputFile) {
this.outputFile = outputFile;
}
@Override
public void notify(float progress) {
str.append("==============Progress: ").append(progress).append("%==============\n");
try {
Files.writeString(Paths.get(outputFile), str.toString());
} catch (Exception e) {
e.printStackTrace();
}
}
}
//using
PdfDocument pdf=new PdfDocument();
pdf.loadFromFile("test.pdf");
pdf.registerProgressNotifier(new CustomProgressNotifier("Progress.txt"));
pdf.saveToFile("out.docx", FileFormat.DOCX);
pdf.dispose();
问题修复:
- 修复了SVG 转PDF ,内容不一致的问题。
- 修复了数字签名有效性验证结果不正确的问题
Spire.Presentation for Java
新功能:
- 支持压缩图片。
Presentation presentation = new Presentation();
presentation.loadFromFile(inputFile);
SlideCollection slides = presentation.getSlides();
for (int i = 0; i < slides.getCount(); i++) {
ISlide slide = slides.get(i);
ShapeCollection shapes = slide.getShapes();
for (int j = 0; j < shapes.getCount(); j++) {
IShape shape = shapes.get(j);
if (shape instanceof SlidePicture) {
SlidePicture slidepicture = (SlidePicture) shape;
// 压缩图片,目标分辨率50 DPI(数值越小压缩越大)
boolean result = slidepicture.getPictureFill().getCompressImage( true, 50f);
}
}
}
问题修复:
- 修复了 PPT 转 PDF,背景色不正确的问题。







