Spire.Office for Java 9.4.0 已发布。在该版本中,Spire.Doc for Java 支持加载、操作和转换 Markdown 文档;Spire.PDF for Java 支持获取关键字的字体名和字体大小;Spire.XLS for Java 新增了一个转换工作表到 SVG 文档的方法;Spire.Barcode for Java 支持在二维码中间添加图片。此外,许多已知问题也在该版本中成功修复。详情请阅读以下内容。
获取 Spire.Office for Java 9.4.0 请点击:https://www.e-iceblue.cn/Downloads/Spire-Office-JAVA.html
Spire.Doc for Java
新功能:
- 支持了加载操作 MarkDown 文档,或转换 Word 格式文档到 MarkDown。
Document doc = new Document();
//load .md file
doc.loadFromFile("input.md");
//save to .md file
doc.saveToFile("output.md", com.spire.doc.FileFormat.Markdown);
//save to .docx file
//doc.saveToFile("output.docx", com.spire.doc.FileFormat.Docx);
//save to .doc file
//doc.saveToFile("output.doc", com.spire.doc.FileFormat.Doc);
//save to .pdf file
//doc.saveToFile("output.pdf", com.spire.doc.FileFormat.PDF);
doc.close();
Document doc = new Document();
//load .docx file
doc.loadFromFile("input.docx");
//load .doc file
//doc.loadFromFile("input.doc");
//save to .md file
doc.saveToFile("output.md", com.spire.doc.FileFormat.Markdown);
doc.close();
问题修复:
- 修复了转换 Word 到 PDF 后内容格式不一致的问题。
- 修复了替换书签内容后,文档其他内容被改变的问题。
- 优化了 Word 转换 PDF 结果文档的大小。
- 修复了比较的结果文档打开报错的问题。
- 修复了转换 Word 到 HTML 后内容格式不正确的问题。
- 修复了转换 Word 到 PDF 时,在未安装任何字体的linux 环境上报 "Cannot found font insatlled on the system" 错误的问题。
- 修复了转换 Word 到 SVG 后页数不正确的问题。
- 修复了加载 ODT 文件,报 ”Error loading file: Unsupported file format“ 错误的问题。
- 修复了生成的 Word 文档使用苹果移动端微信打不开的问题。
- 优化了 FixedLayoutLine.getRectangle() 方法,可以获取其高宽,例如 FixedLayoutLine.getRectangle().width 和 FixedLayoutLine.getRectangle().height。
Spire.PDF for Java
新功能:
- 支持获取关键字的字体名和字体大小。
- PdfTextReplacer 类支持通过正则表达式匹配。
PdfDocument pdf = new PdfDocument();
pdf.loadFromFile(inputFile);
PdfPageBase page = pdf.getPages().get(0);
PdfTextFinder finds = new PdfTextFinder(page);
finds.getOptions().setTextFindParameter(EnumSet.of(TextFindParameter.IgnoreCase));
List<PdfTextFragment> result = finds.findAllText(page);
StringBuilder str = new StringBuilder();
for (PdfTextFragment find : result)
{
str.append("FontName:"+find.getTextStates()[0].getFontName());
str.append("FontSize:"+find.getTextStates()[0].getFontSize());
str.append("FontFamily:"+find.getTextStates()[0].getFontFamily());
str.append("Bold:"+find.getTextStates()[0].isBold());
str.append("Italic:"+find.getTextStates()[0].isItalic());
str.append("ForegroundColor:"+find.getTextStates()[0].getForegroundColor());
}
PdfDocument doc = new PdfDocument();
doc.loadFromFile("input.pdf");
PdfTextReplaceOptions textReplaceOptions = new PdfTextReplaceOptions();
textReplaceOptions.setReplaceType(EnumSet.of(ReplaceActionType.Regex));
PdfPageBase page = doc.getPages().get(0);
PdfTextReplacer textReplacer = new PdfTextReplacer(page);
textReplacer.setOptions(textReplaceOptions);
String regularExpression = "\\bS\\w*L\\b";
textReplacer.replaceAllText(regularExpression, "NEW");
doc.saveToFile("output.pdf");
doc.dispose();
问题修复:
- 修复了转换后的 PDFA2B 文件未通过验证的问题。
Spire.XLS for Java
新功能:
- 新增了一个转换 Excel 工作表到 SVG 文档的方法,支持返回 SVG 的尺寸。
Workbook workbook = new Workbook();
workbook.loadFromFile("1.xlsx");
Worksheet sheet =workbook.getWorksheets().get(0);
FileOutputStream stream = new FileOutputStream(outputFile);
Dimension dimension=sheet.toSVGStream(stream, sheet.getFirstRow(), sheet.getFirstColumn(), sheet.getLastRow(), sheet.getLastColumn());
double Height=dimension.getHeight();
double Width=dimension.getWidth();
问题修复:
- 修复了转换 Excel 文档到 PDF 文档时文本位置不正确的问题。
- 修复了转换 Excel 文档到 HTML 文档时超链接丢失的问题。
- 修复了在日文语言环境下转换 Excel 文档到 PDF 文档时右边距增加的问题。
- 修复了转换 Excel 文档到 PDF 文档时内容丢失的问题。
- 修复了添加自定义过滤器不生效的问题。
- 修复了转换 Excel 文档到 PDF 文档时图片比例被改变的问题。
- 修复了转换 HTML 文档到 Excel 文档时程序悬挂不停止的问题。
- 修复了转换 Excel 文档到 HTML 文档时表格不完整的问题。
Spire.Presentation for Java
问题修复:
- 修复了多线程下转换大量的文档,线程池内的任务结束后,CPU 占用达到百分之百并内存溢出的问题。
Spire.Barcode for Java
新功能:
- 应用授权的方法更改为com.spire.barcode.license.LicenseProvider.setLicenseKey(key)。
- 支持在二维码中间添加图片。
BarcodeSettings barCodeSetting = new BarcodeSettings();
BufferedImage image = ImageIO.read(new File("Image/1.png"));
barCodeSetting.setQRCodeLogoImage(image);
问题修复:
- 修复了垂直方向的条形码识别失败的问题。