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码,得到的数据错误的问题。