We are delighted to announce the release of Spire.Office for Java 9.1.4. In this version, Spire.PDF for Java improves the efficiency of drawing watermarks; Spire.Doc for Java adds a new method to add image watermark; Spire.Presentation for Java improves the speed of converting PowerPoint to SVG. In addition, many known issues are fixed in this version. More details are listed below.
Click the link to download Spire.Office for Java 9.1.4:
Here is a list of changes made in this release
Spire.PDF for Java
Category | ID | Description |
New feature | SPIREPDF-6454 | Improves the efficiency of drawing watermarks. |
New feature | SPIREPDF-6459 | Adds the PdfTextReplacer interface to implement text replacement function.
PdfDocument pdf = new PdfDocument(); pdf.loadFromFile("sample.pdf"); PdfPageBase page = pdf.getPages().get(0); PdfTextReplacer replacer = new PdfTextReplacer(page); PdfTextReplaceOptions options= new PdfTextReplaceOptions(); options.setReplaceType(EnumSet.of(ReplaceActionType.WholeWord)); replacer.replaceText("www.google.com", "1234567"); pdf.saveToFile(outputFile); |
New feature | - | Adds the PdfImageHelper interface to implement image deletion, extraction, replacement, and compression functions. Key code snippet: PdfImageHelper imageHelper = new PdfImageHelper(); PdfImageInfo[] imageInfoCollection= imageHelper.getImagesInfo(page); Delete image: imageHelper.deleteImage(imageInfoCollection[0]); Extract image: int index = 0; for (com.spire.pdf.utilities.PdfImageInfo img : imageInfoCollection) { BufferedImage image = img.getImage(); File output = new File(outputFile_Img + String.format("img_%d.png", index)); ImageIO.write(image, "PNG", output); index++; } PdfImage image = PdfImage.fromFile("ImgFiles/E-iceblue logo.png"); imageHelper.replaceImage(imageInfoCollection[i], image); Compress image: for (PdfPageBase page : (Iterable<PdfPageBase>)doc.getPages()) { if (page != null) { if (imageHelper.getImagesInfo(page) != null) { for (com.spire.pdf.utilities.PdfImageInfo info : imageHelper.getImagesInfo(page)) { info.tryCompressImage(); } } } } |
Bug | SPIREPDF-6468 | Fixes the issue that the program threw java.lang.StringIndexOutOfBoundsException exception when saving documents. |
Bug | SPIREPDF-6484 | Fixes the issue that no resulting documents were generated after performing batch text replacement on multiple PDF documents under multi-threading. |
Spire.XLS for Java
Category | ID | Description |
Bug | SPIREXLS-5020 | Fixes the issue that the margins of saved XLSX documents were incorrect when printed and previewed with the WPS tool. |
Bug | SPIREXLS-5037 | Fixes the issue that the obtained fill color value for cells without fill color was (0,0,0). |
Bug | SPIREXLS-5047 | Fixes the issue that the border styles of cells were lost when converting HTML documents to XLSX documents. |
Spire.Doc for Java
Category | ID | Description |
Adjustment | - | Removes the dependency on Spire.Pdf.jar. |
Adjustment | - | Changes the method of license application to "com.spire.doc.license.LicenseProvider.setLicenseKey(key)". |
Adjustment | - | Changes the namespace com.spire.ms.Printing.* to com.spire.doc.printing.* |
New feature | - | Deprecates the following methods, classes and interfaces.
The "newEngine" parameter in the Document constructor no longer has any effect. The internal mechanism now defaults to using the new engine. The HeaderType enum. The GroupedShapeCollection class. The ShapeObjectTextCollection class. The MailMergeData interface. The EnumInterface interface. The public PictureWaterMark(InputStream inputeStream, boolean washout) constructor. The public PictureWaterMark(String filename, boolean washout) constructor. The downloadImage method in the Field class. The IDocOleObject interface. The PointsConverter class. |
New feature | - | Deprecates the "getWidth()" and "setWidth()" methods in the TableCell class and replaces them with the "getCellWidth()" and "setCellWidth()" methods. |
New feature | - | Changes the following namespaces.
com.spire.license.LicenseProvider -> com.spire.doc.License.LicenseProvider |
New feature | - | Changes the inheritance relationship: changes "ShapeGroup implements ShapeObject" to "ShapeGroup implements ShapeBase". |
New feature | - | Supports destroying data related to customized fonts when destroying the Document at the same time.
// Set custom fonts Document.setCustomFontsFolders(string filePath); // Dispose of custom fonts Document.clearCustomFontsFolders(); // Clear system font cache that occupies memory in the cache Document.clearSystemFontCache(); Example code: Document doc = new Document(); doc.loadFromFile("inputFile.docx"); doc.setCustomFontsFolders(@"d:\Fonts"); doc.saveToFile("output.pdf", FileFormat.PDF); doc.close(); doc.dispose(); |
New feature | - | Changes the following enumerated classes.
com.spire.doc.FileFormat.WPS -> com.spire.doc.FileFormat.Wps com.spire.doc.FileFormat.WPT -> com.spire.doc.FileFormat.Wpt ComparisonLevel -> TextDiffMode |
New feature | - | Changes the following methods.
ComparisonLevel getLevel() -> getTextCompareLevel() setLevel(ComparisonLevel value) -> setTextCompareLevel(TextDiffMode) IsPasswordProtect() -> isEncrypted() getFillEfects() -> getFillEffects() |
New feature | - | Adds a new method to add image watermark.
File imageFile = new File("data/E-iceblue.png"); BufferedImage bufferedImage = ImageIO.read(imageFile); // Create a new instance of the PictureWatermark class with the input BufferedImage, and set the scaling factor for the watermark image PictureWatermark picture = new PictureWatermark(bufferedImage,false); // Or another way to create PictureWatermark // PictureWatermark picture = new PictureWatermark(); // picture.setPicture(bufferedImage); // picture.isWashout(false); // Set the scaling factor for the watermark image picture.setScaling(250); // Set the watermark to be applied to the document document.setWatermark(picture); |
New feature | - | shape exposes the "getFill()" method to manipulate the fill of a shape; please use "getFill().setOn(false)" instead of "setFillColor(null)". |
New feature | - | Supports adding charts.
// Create a new instance of Document Document document = new Document(); // Add a section to the document Section section = document.addSection(); // Add a paragraph to the section and append text to it section.addParagraph().appendText("Line chart."); // Add a new paragraph to the section Paragraph newPara = section.addParagraph(); // Append a line chart shape to the paragraph with specified width and height ShapeObject shape = newPara.appendChart(ChartType.Line, 500, 300); // Get the chart object from the shape Chart chart = shape.getChart(); // Get the title of the chart ChartTitle title = chart.getTitle(); // Set the text of the chart title title.setText("My Chart"); // Clear any existing series in the chart ChartSeriesCollection seriesColl = chart.getSeries(); seriesColl.clear(); // Define categories (X-axis values) String[] categories = { "C1", "C2", "C3", "C4", "C5", "C6" }; // Add two series to the chart with specified categories and Y-axis values seriesColl.add("AW Series 1", categories, new double[] { 1, 2, 2.5, 4, 5, 6 }); seriesColl.add("AW Series 2", categories, new double[] { 2, 3, 3.5, 6, 6.5, 7 }); // Save the document to a file in Docx format document.saveToFile("AppendLineChart.docx", FileFormat.Docx_2016); // Dispose of the document object when finished using it document.dispose(); |
New feature | - | Provides the page model "Spire.Doc.Pages" to get the content of the page.
// Create a new instance of Document Document doc = new Document(); // Load the document from the specified file doc.loadFromFile(inputFile); // Create a FixedLayoutDocument object using the loaded document FixedLayoutDocument layoutDoc = new FixedLayoutDocument(doc); // Create a StringBuilder to store the extracted text StringBuilder stringBuilder = new StringBuilder(); // Get the first line on the first page and append it to the StringBuilder FixedLayoutLine line = layoutDoc.getPages().get(0).getColumns().get(0).getLines().get(0); stringBuilder.append("Line: " + line.getText() + "\r\n"); // Retrieve the original paragraph associated with the line and append its text to the StringBuilder Paragraph para = line.getParagraph(); stringBuilder.append("Paragraph text: " + para.getText() + "\r\n"); // Retrieve all the text on the first page, including headers and footers, and append it to the StringBuilder String pageText = layoutDoc.getPages().get(0).getText(); stringBuilder.append(pageText + "\r\n"); // Iterate through each page in the document and print the number of lines on each page for (Object obj : layoutDoc.getPages()) { FixedLayoutPage page = (FixedLayoutPage) obj; LayoutCollection<LayoutElement> lines = page.getChildEntities(LayoutElementType.Line, true); stringBuilder.append("Page " + page.getPageIndex() + " has " + lines.getCount() + " lines." + "\r\n"); } // Perform a reverse lookup of layout entities for the first paragraph and append them to the StringBuilder stringBuilder.append("\r\n"); stringBuilder.append("The lines of the first paragraph:" + "\r\n"); for (Object object : layoutDoc.getLayoutEntitiesOfNode(((Section) doc.getFirstChild()).getBody().getParagraphs().get(0))) { FixedLayoutLine paragraphLine = (FixedLayoutLine) object; stringBuilder.append(paragraphLine.getText().trim() + "\r\n"); stringBuilder.append(paragraphLine.getRectangle().toString() + "\r\n"); stringBuilder.append(""); } // Write the extracted text to a file FileWriter fileWriter = new FileWriter(new File(outputFile)); fileWriter.write(stringBuilder.toString()); fileWriter.flush(); fileWriter.close(); // Dispose of the document resources doc.close(); doc.dispose(); |
New feature | - | Supports adding SVG graphics.
// Create a new Document object Document document = new Document(); // Add a new Section to the document Section section = document.addSection(); // Add a new Paragraph to the section Paragraph paragraph = section.addParagraph(); // Append the picture (SVG) to the paragraph paragraph.appendPicture(inputSvg); // Save the document to the specified output file document.saveToFile(outputFile, FileFormat.Docx_2013); // Close the document document.dispose(); |
Bug | SPIREDOC-8618 | Fixes the issue that the program threw "Error loading file: Unsupported file format" exception when converting Doc to Docx. |
Bug | SPIREDOC-8694 | Fixes the issue that the position of the shape was shifted when converting Word to PDF. |
Bug | SPIREDOC-8779 | Fixes the issue that the program threw "java.lang.OutOfMemoryError" exception when converting Word to PDF. |
Bug | SPIREDOC-8981 | Fixes the issue that there were extra borders around images when converting Word to PDF. |
Bug | SPIREDOC-9321 | Fixes the issue that the table width was incorrect when converting Word to PDF. |
Bug | SPIREDOC-9426 SPIREDOC-9427 SPIREDOC-9953 SPIREDOC-9964 SPIREDOC-10131 |
Fixes the issue that the pagination was incorrect when converting Word to PDF. |
Bug | SPIREDOC-9465 | Fixes the issue that the content was lost when converting Doc to XML. |
Bug | SPIREDOC-9551 | Fixes the issue that the program hung when saving document data to a memory stream. |
Bug | SPIREDOC-9633 | Fixes the issue that text became garbled when converting Word to PDF. |
Bug | SPIREDOC-9695 | Fixes the issue that the program threw "This is not a structured storage file." exception when converting Word to a PDF. |
Bug | SPIREDOC-9874 | Fixes the issue that the table styles were incorrect when converting Word to PDF. |
Bug | SPIREDOC-9917 SPIREDOC-9937 |
Fixes the issue that the program threw "java.lang.AssertionError" exception when converting Word to PDF. |
Bug | SPIREDOC-9951 | Fixes the issue that the content was lost when converting Word to PDF. |
Bug | SPIREDOC-9968 | Fixes the issue that the table format was incorrect after adding new rows and merging rows. |
Bug | SPIREDOC-9984 | Fixes the issue that the program threw "java.lang.NullPointerException" exception when converting Word to PDF. |
Bug | SPIREDOC-10041 | Fixes the issue that the program threw "java.lang.ClassCastException" exception when converting Word to PDF. |
Bug | SPIREDOC-10075 | Fixes the issue that the formulas could not be edited after merging Word documents. |
Bug | SPIREDOC-10076 | Fixes the issue that the chart data format was incorrect when converting Word to PDF. |
Bug | SPIREDOC-10115 | Fixes the issue that the program threw "java.lang.NullPointerException" exception when loading a Word document. |
Bug | SPIREDOC-10125 | Fixes the issue that the background of some content was blackened after setting a document password protection. |
Bug | SPIREDOC-10136 | Fixes the issue that the tables were misaligned after splitting cells. |
Spire.OCR for Java
Category | ID | Description |
Bug | - | Fixes the issue that the program threw “java.lang.NoClassDefFoundError” exception when running under JDK17 and JDK21. |
Spire.Presentation for Java
Category | ID | Description |
New feature | SPIREPPT-2395 | Improves the speed of converting PowerPoint to SVG. |
New feature | SPIREPPT-2400 | Adds a method to load encrypted stream files.
presentation.loadFromStream(inputStream, FileFormat.AUTO,"password"); |
New feature | SPIREPPT-2405 | Supports creating irregular polygons using coordinates.
Presentation ppt = new Presentation(); ISlide slide = ppt.getSlides().get(0); List<Point2D> points = new ArrayList<>(); points.add(new Point2D.Float(50f, 50f)); points.add(new Point2D.Float(50f, 150f)); points.add(new Point2D.Float(60f, 200f)); points.add(new Point2D.Float(200f, 200f)); points.add(new Point2D.Float(220f, 150f)); points.add(new Point2D.Float(150f, 90f)); points.add(new Point2D.Float(50f, 50f)); IAutoShape autoShape = slide.getShapes().appendFreeformShape(points); autoShape.getFill().setFillType(FillFormatType.NONE); ppt.saveToFile("out.pptx", FileFormat.PPTX_2013); ppt.dispose(); |
New feature | SPIREPPT-2406 | Supports drawing lines using two points.
Presentation ppt = new Presentation(); ppt.getSlides().get(0).getShapes().appendShape(ShapeType.LINE, new Point2D.Float(50, 70), new Point2D.Float(150, 120)); ppt.saveToFile( "result.pptx ,FileFormat.PPIX_2013), ppt.dispose(). |