Spire.Office for Java 3.9.4

Spire.Office for Java 3.9.4 is released

We're pleased to announce the release of Spire.Office for Java 3.9.4. The new version released has a series of features, for example, Spire.Doc for Java supports comparing two Word documents; Spire.PDF for Java supports converting SVG to PDF; Spire.XLS for Java supports converting Excel to a TIFF file; Spire.Presentation for Java supports updating the Video data of PPT files and Spire.Barcode for Java supports setting the alignment of the barcode top text. Meanwhile, some issues that occurred when loading, manipulating and converting Word, Excel, PDF and Presentation as well as scanning barcode have been fixed successfully. More details are listed in the following tables.

Click the link to download Spire.Office for Java 3.9.4:

Here is a list of changes made in this release

Spire.Doc for Java

Category ID Description
New Feature SPIREDOC-3359 Supports comparing two Word documents.
Document doc1 = new Document();
doc1.loadFromFile(inputFile_1);
Document doc2 = new Document();
doc2.loadFromFile(inputFile_2);
doc1.compare(doc2, "E-iceblue");
doc1.saveToFile(outputFile);
New Feature SPIREDOC-4856 Supports clearing background of table cell.
tablecell.getCellFormat().clearBackground();
New Feature SPIREDOC-4857 Supports setting the resolution when converting Word to image.
doc.saveToImages(pageIndex, pageCount, ImageType.Bitmap, dpiX, dpiY);
Optimization SPIREDOC-4707 Optimizes the time of loading Word document.
Optimization SPIREDOC-4790 Optimizes the time of converting Word to PDF.
Bug SPIREDOC-4708 Fixes the issue that there were extra boxes when converting html to pdf.
Bug SPIREDOC-4717 Fixes the issue that the line lost when converting Word to PDF.
Bug SPIREDOC-4845 Fixes the issue that caused incorrect content when converting Word to PDF.
Bug SPIREDOC-4852 Fixes the issue that setting the background color of textbox as no filling didn't take effect.
Bug SPIREDOC-4864 Fixes the issue that the table was paginated after saving to .doc.
Bug SPIREDOC-4866 Fixes the issue that the position of cross-reference was incorrect after adding captions to the table and picture.
Bug SPIREDOC-4771 Fixes the issue that the application threw "IllegalArgumentException" when loading document.
Bug SPIREDOC-4833 Fixes the issue that after adding image in header, the generated .docx hinted the content has error when opening with MS Word 2007.
Bug SPIREDOC-4838 Fixes the issue that the track changes was incorrect after saving.
Bug SPIREDOC-4841 Fixes the issue that the content format was incorrect after converting Word to Image.
Bug SPIREDOC-3721 Fixes the issue that the application threw ArrayIndexOutOfBoundsException when getting page count.
Bug SPIREDOC-3964 Fixes the issue that the application threw "Specified method is not supported" when removing section break
Bug SPIREDOC-4373
SPIREDOC-4416
SPIREDOC-4426
Fixes the issue that the application threw StackOverflowError when updating TOC after inserting TOC
Bug SPIREDOC-4377
SPIREDOC-4387
Fixes the issue that the application threw "No have this value 3" when loading file.
Bug SPIREDOC-4414 Fixes the issue that the application threw "Index is less than 0 or more than or equal to the list count" when updating TOC after inserting TOC.
Bug SPIREDOC-4925 Fixes the issue that the application threw "com.spire.doc.packages.sprezB: No have this value 4" when converting Doc to Images.
Bug SPIREDOC-4695 Fixes the issue that the value of heading1 field was incorrect when converting Word to PDF.

Spire.PDF for Java

Category ID Description
New Feature SPIREPDF-3545 Supports converting SVG to PDF.
PdfDocument doc = new PdfDocument();
doc.loadFromSvg(inputFile_svg);
doc.saveToFile(outputFile);
New Feature SPIREPDF-3545 Supports adding SVG picture to PDF.
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();
New Feature SPIREPDF-3533 Supports converting PDF to Excel.
PdfDocument pdf = new PdfDocument();
pdf.loadFromFile(inputFile);
pdf.saveToFile(outputPath, FileFormat.XLSX);
New Feature - Supports converting PDF to Word with flow layout.
PdfDocument pdf = new PdfDocument();
pdf.loadFromFile(inputFile);
pdf.getConvertOptions().setConvertToWordUsingFlow(true);
pdf.saveToFile(outputFile_doc, FileFormat.DOC);
Bug SPIREPDF-3516 Fixes the issue that the Arabic text was not drawn correctly.
Bug SPIREPDF-3542 Fixes the issue that it got garbled text after extracting text from PDF.
Bug SPIREPDF-3486 Fixes the issue that it caused incorrect content after converting PDF to image on Ubuntu system.
Bug SPIREPDF-3490 Fixes the issue that it caused extra dotted lines after converting PDF to image.
Bug SPIREPDF-3507 Fixes the issue that stamp was lost after converting PDF to image.

Spire.XLS for Java

Category ID Description
New Feature SPIREXLS-2099 Adds "workbook.saveToTiff(String Filename)" method to support converting Excel to a TIFF file.
New Feature SPIREXLS-2634 Supports setting dpi when converting Excel to Image.
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");
}
Bug SPIREXLS-2781 Optimizes time performance for converting Excel to HTML
Bug SPIREXLS-2284 Fixes the issue that the application threw NumberFormatException when converting Excel to PDF.
Bug SPIREXLS-2630 Fixes the issue that the application threw an error "Size of image is too large" when converting Excel to image.
Bug SPIREXLS-2635 Fixes the issue that the application threw an error "java.lang.IllegalStateException: Cannot find a required cmap table." when converting Excel to Images on Ubuntu.
Bug SPIREXLS-2683 Fixes the issue that the content of converted image was not clear when converting Excel to Images.
Bug SPIREXLS-2695 Fixes the issue that the number format was incorrect when converting Excel to PDF
Bug SPIREXLS-2696 Fixes the issue that it failed to get document properties of XLS file.
Bug SPIREXLS-2748 Fixes the issue that the inserted background images into XLS documents did not appear.
Bug SPIREXLS-2755 Fixes the issue that the value of number was incorrect when converting Excel to HTML.

Spire.Presentation for Java

Category ID Description
New Feature SPIREPPT-1273 Supports getting the effect of the animation.
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);
//Gets preset type,likes Entrance,Emphasis,Exit,Path
String presetClassType = animationEffect.getPresetClassType().getName();
//Gets animation effect type
AnimationEffectType animationEffectType= animationEffect.getAnimationEffectType();
//Gets target shape
Shape shape = animationEffect.getShapeTarget();
//Gets sub type of animation effect
String subType = animationEffect.getSubtype().getName();
//Gets color
Color color = animationEffect.getColor();
//Gets the vanishing point of Faded_Zoom animation
if (animationEffectType.equals(AnimationEffectType.FADED_ZOOM)) {
String vanishingPointName = animationEffect.getVanishingPoint().getName();
                }
//Gets Wave animation effects
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();
                        }
                    }
                }
            }
        }
New Feature SPIREPPT-1240 Supports updating the Video data of PPT files.
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);
New Feature SPIREPPT-1270 Supports getting the PartName property of Audio and Video. 
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();
                }
            }
        }
New Feature SPIREPPT-1268 Supports getting the Amount property of the emphasized type animation.
for (int i = 0; i < slide.getTimeline().getMainSequence().getCount(); i++) {
            AnimationEffect animationEffect = slide.getTimeline().getMainSequence().get(i);
            AnimationAmountType amount = animationEffect.getAmount();
        }
optimization SPIREPPT-1161 Optimizes the file size of the generated PPT file.
Bug SPIREPPT-1296 Fixes the issue that the content of chart axis was not formatted correctly when converting .pptx to pdf.
Bug SPIREPPT-1107 Fixes the issue that the line position was incorrect when converting PPT to PDF.
Bug SPIREPPT-1166 Fixes the issue that it failed to set the underline of text range.
Bug SPIREPPT-1167 Fixes the issue that the created scatter chart with straight lines had needless markers.
Bug SPIREPPT-1183 Fixes the issue that the application threw "NullReferenceException" when saving the PPTX file.
Bug SPIREPPT-1219 Fixes the issue that setting the duration for animation didn't take effect.
Bug SPIREPPT-1238 Fixes the issue that the application threw "NullPointerException" when converting PPT to PDF.
Bug SPIREPPT-1239 Fixes the issue that the application threw the error "Unknown char: 林" when saving the file and reordering slides.
Bug SPIREPPT-1247 Fixes the issue that the duration of the animation obtained was incorrect.
Bug SPIREPPT-1248 Fixes the issue that the application threw "NullPointerException" when getting animation motion points.
Bug SPIREPPT-1252 Fixes the issue that it couldn’t get the animations of PPT file.
Bug SPIREPPT-1257 Fixes the issue that the br tag don’t take effect after inserting HTML string to PPT.
Bug SPIREPPT-1268 Fixes the issue that the Subtype property of the animation couldn’t be got.

Spire.Barcode for Java

Category ID Description
New Feature SPIREBARCODE-126 Supports setting the alignment of the barcode top text.
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"));
New Feature SPIREBARCODE-155 Supports adding custom text at the bottom of the barcode.
barsetting.setBottomText("EAN");
barsetting.setBottomTextFont(new Font("fangsong", Font.BOLD, 25));
barsetting.setBottomTextColor(Color.BLACK);
barsetting.setShowBottomText(true);
barsetting.setBottomTextAlignment(StringAlignment.Center);
Bug SPIREBARCODE-85
SPIREBARCODE-113
SPIREBARCODE-156
Fixes the issue that the scan result was incorrect.
Bug SPIREBARCODE-101
SPIREBARCODE-106
SPIREBARCODE-157
Fixes the issue that scanning the barcode failed.
Bug SPIREBARCODE-146 Fixes the issue that the application threw “NullPointerException” when scanning barcode.
Bug SPIREBARCODE-154 Fixes the issue that adding custom text did not take effect.
Bug SPIREBARCODE-156 Fixes the issue that the scan result was incorrect when scanning QR code with special characters.