Spire.Office for Java 9.7.0 is released

2024-08-01 02:55:42

We're pleased to announce the release of Spire.Office for Java 9.7.0. This version contains many new features, such as Spire.Doc for Java supports embedding CSS and images when converting Word documents to HTML files in HTML Fixed format; Spire.Presentation for Java supports adding comments to specified text in PowerPoint; Spire.Barcode for Java supports obtaining barcode information, including barcode type, data value and vertex position information. In addition, many known issues have also been successfully fixed in this version. More details are listed below.

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

Here is a list of changes made in this release

Spire.Doc for Java

Category ID Description
New feature SPIREDOC-10687 Supports embedding CSS and images when converting Word documents to HTML files in HTML Fixed format.
String inputFile = "1.docx";
String outputFile ="1.html";
Document doc = new Document();
doc.loadFromFile(inputFile);
doc.getHtmlExportOptions().setCssStyleSheetType(CssStyleSheetType.Internal);
doc.getHtmlExportOptions().setImageEmbedded(true);
doc.saveToFile(outputFile, FileFormat.HtmlFixed);
doc.dispose();
Bug SPIREDOC-9829
SPIREDOC-10609
Fixes the issue that the orientation of added images was incorrect.
Bug SPIREDOC-10006
SPIREDOC-10636
SPIREDOC-10692
Fixes the issue that the size of OFD documents converted from Docx documents becomes bigger.
Bug SPIREDOC-10327 Fixes the issue that watermarks in HTML documents converted from Docx documents were lost.
Bug SPIREDOC-10379
SPIREDOC-10509
SPIREDOC-10531
SPIREDOC-10650
Fixes an issue that content was lost after converting a Docx document to a PDF document.
Bug SPIREDOC-10591 Fixes an issue that the editing area was lost after converting an XML document to a Doc document.
Bug SPIREDOC-10615 Fixes the issue that the program threw an exception when converting Word to PDF under multi-threading.
Bug SPIREDOC-10623 Fixes the issue that page numbers were formatted incorrectly after converting Docx documents to PDF documents.
Bug SPIREDOC-10627 Fixes the issue that the program threw "The authentication or decryption has failed." error when converting Docx documents to PDF documents.
Bug SPIREDOC-10634
SPIREDOC-10701
Fixes the issue that the program threw an exception when converting Word to OFD under multi-threading.
Bug SPIREDOC-10670 Fixes the issue that the text orientation changed after converting Docx documents to PDF documents.
Bug SPIREDOC-10685
SPIREDOC-10697
Fixes the issue that the page numbers of requests after the second time were lost after adding a table of contents in a Web project.
Bug SPIREDOC-10713 Fixes the issue that font embedding failed when converting Docx documents to PDF documents.

Spire.PDF for Java

Category ID Description
Bug SPIREPDF-6804 Fixes the error occurred when opening compressed PDF files.
Bug SPIREPDF-6831 Fixed the issue that the effect of the PdfInkAnnotation added to PDF was incorrect.
Bug SPIREPDF-6856 Fixes the issue that the program threw "NullPointerException" when obtaining the PDF JavaScript.
Bug SPIREPDF-6865 Fixes the issue that the program threw "java.lang.NoClassDefFoundError" when compressing images with the "ImageQuality.Medium" setting.
Bug SPIREPDF-6870 Fixed the issue that the size of PDF documents was not reduced after splitting.
Bug SPIREPDF-6879 Fixes the issue of creating a PdfActionAnnotation but retrieving its type as PdfTextWebLinkAnnotationWidget.
Bug SPIREPDF-6886 Fixes the issue that the program threw "NullPointerException" when replacing text in PDF.

Spire.Presentation for Java

Category ID Description
New feature SPIREPPT-2559 Supports adding comments to specified text in PowerPoint.
Presentation ppt = new Presentation();
ISlide slide = ppt.getSlides().get(0);
IAutoShape shape = ppt.getSlides().get(0).getShapes().appendShape(ShapeType.RECTANGLE, new Rectangle2D.Double(100, 250, 350, 200));
ppt.getSlides().get(0).getShapes().get(0).getLine().getFillFormat().getSolidFillColor().setColor(Color.white);
shape.getFill().setFillType(FillFormatType.SOLID);
shape.getFill().getSolidColor().setColor(Color.GRAY);
ParagraphEx paragraphEx = shape.getTextFrame().getTextRange().getParagraph();
PortionEx ex = new PortionEx("TextTextmdTextText\ttmdTextTextmdText\ttmdTextTextmdtEXT\ttTextmd");
paragraphEx.getTextRanges().append(ex);
ICommentAuthor commentAuthor = ppt.getCommentAuthors().addAuthor("test","12");
paragraphEx.addComment(commentAuthor,slide,shape,ex,"123");
String result = "result.pptx";
ppt.saveToFile(result, FileFormat.PPTX_2013);

Presentation ppt = new Presentation();
ppt.loadFromFile(inputFile);
ISlide slide = ppt.getSlides().get(0);
IAutoShape shape = (IAutoShape) slide.getShapes().get(0);
ParagraphEx paragraphEx = shape.getTextFrame().getTextRange().getParagraph();
PortionEx portionEx = paragraphEx.getTextRanges().get(0);
ICommentAuthor commentAuthor = ppt.getCommentAuthors().addAuthor("test","18");
paragraphEx.addComment(commentAuthor,slide,shape,portionEx,"123456789");
String result = "result.pptx";
ppt.saveToFile(result, FileFormat.PPTX_2013);
Bug SPIREPPT-2550 Fixes the issue that the shape height was incorrect after adding content to the shape.
Bug SPIREPPT-2560 Fixes the issue that the effect of modifying the shape position was incorrect.
Bug SPIREPPT-2561 Fixes the issue that the greater-than and less-than symbols in Latex formulas were parsed incorrectly.

Spire.Barcode for Java

Category ID Description
New feature SPIREBARCODE-258 The BarcodeScanner class supports obtaining barcode information, including barcode type, data value and vertex position information.
BarcodeInfo[] infos = BarcodeScanner.scanInfo("barcode.png");
Point[] loaction = infos[0].getVertexes();
BarCodeReadType barCodeReadType = infos[0].getReadType();
String dataString =  infos[0].getDataString();
New feature - The BarcodeScanner class supports scanning Aztec type.
String[] s = BarcodeScanner.scan("AZTEC.png",BarCodeType.Aztec);
New feature - The BarcodeScanner class supports scanning with more overload settings.
Public static String[] scan(BufferedImage bitmap, java.awt.Rectangle rect, BarCodeType barcodeType, boolean IncludeCheckSum)
Public static String[] scan(String fileName, BarCodeType barcodeType, boolean IncludeCheckSum)
Public static String scanOne(String fileName, BarCodeType barcodeType, boolean IncludeCheckSum)
Public static String scanOne(InputStream stream, BarCodeType barcodeType, boolean IncludeCheckSum)
New feature - Adds external use enumerations.
com.spire.barcode.publics.drawing.FontStyle
com.spire.barcode.publics.drawing.GraphicsUnit
com.spire.barcode.publics.drawing.StringAlignment
New feature - Adjustments to the IBarCodeSettings interface.

Recycled:

public java.awt.Font getTopTextFont()
public java.awt.Font getBottomTextFont()
public java.awt.Font getTextFont()

Modified:

public void setBottomTextFont(java.awt.Font value)->public void setBottomTextFont(String familyName, float fontSize)
public void setTopTextFont(java.awt.Font value)->public void setTopTextFont(String familyName, float fontSize)
public boolean showBottomText->public boolean isShowBottomText()
public void setShowBottomText(boolean value) -> public void isShowBottomText(boolean value)
public com.spire.barcode.GraphicsUnit getUnit() -> public com.spire.barcode.publics.drawing.GraphicsUnit getUnit()
public void setUnit(com.spire.barcode.GraphicsUnit value) -> public void setUnit(com.spire.barcode.publics.drawing.GraphicsUnit value)
public void setTextFont(java.awt.Font value) -> public void setTextFont(String familyName, float fontSize)
public float getLeftMargin() ->The default value adjusted from 5 to 4. 

Newly Added:

public float getTopTextMargin()  
public void setTopTextMargin(float value)
public int getAztecErrorCorrection()
public void setAztecErrorCorrection(int value)
public int getAztecLayers()
public void setAztecLayers(int value)
public DataMatrixSymbolShape getDataMatrixSymbolShape()
public void setDataMatrixSymbolShape(DataMatrixSymbolShape value)
public ITF14BorderType getITF14BearerBars() 
public void setITF14BearerBars(ITF14BorderType value)
public void setTextFont(String familyName, float fontSize, com.spire.barcode.publics.drawing.FontStyle style)
public boolean isShowStartCharAndStopChar()
public void isShowStartCharAndStopChar(boolean value)
New feature - Adjustments to the BarcodeSettings class interfaces.

Recycled:

public java.awt.Font getTextFont()
public java.awt.Font getTopTextFont() 
public java.awt.Font getBottomTextFont()

Modified:

public void setTextFont(java.awt.Font value) -> public void setTextFont(String familyName, float sizePoints)
public com.spire.barcode.GraphicsUnit getUnit() -> public com.spire.barcode.publics.drawing.GraphicsUnit getUnit()
public void setUnit(com.spire.barcode.GraphicsUnit value) -> public void setUnit(com.spire.barcode.publics.drawing.GraphicsUnit value)
public com.spire.barcode.StringAlignment getTextAlignment() -> public com.spire.barcode.publics.drawing.StringAlignment getTextAlignment()
public void setTextAlignment(com.spire.barcode.StringAlignment value) -> public void setTextAlignment(com.spire.barcode.publics.drawing.StringAlignment value)
public com.spire.barcode.StringAlignment getTopTextAligment() -> public com.spire.barcode.publics.drawing.StringAlignment getTopTextAligment()
public void setTopTextAligment(com.spire.barcode.StringAlignment value) -> public void setTopTextAligment(com.spire.barcode.publics.drawing.StringAlignment value)
public void setBottomTextFont(java.awt.Font value) -> public void setBottomTextFont(String familyName, float fontSize)
public void setTopTextFont(java.awt.Font value) -> public void setTopTextFont(String familyName, float fontSize)
public boolean showBottomText->public boolean isShowBottomText()
public void setShowBottomText(boolean value) -> public void isShowBottomText(boolean value)
public com.spire.barcode.StringAlignment getBottomTextAlignment() -> public com.spire.barcode.publics.drawing.StringAlignment getBottomTextAlignment()
public void setBottomTextAlignment(com.spire.barcode.StringAlignment value) -> public void setBottomTextAlignment(com.spire.barcode.publics.drawing.StringAlignment value)
public float getLeftMargin() ->The default value adjusted from 5 to 4. 

Newly Added:

public float getTopTextMargin()
public void setTopTextMargin(float value)
public void setTextFont(String familyName, float sizePoints, com.spire.barcode.publics.drawing.FontStyle style)
public void setTopTextFont(String familyName, float fontSize, com.spire.barcode.publics.drawing.FontStyle style)
public void setITF14BearerBars(ITF14BorderType value)
public boolean isShowStartCharAndStopChar()
public void isShowStartCharAndStopChar(boolean value)
public int getAztecLayers()
public void setAztecLayers(int value)
public int getAztecErrorCorrection()
public void setAztecErrorCorrection(int value)
public DataMatrixSymbolShape getDataMatrixSymbolShape()
public void setDataMatrixSymbolShape(DataMatrixSymbolShape value)
public void setBottomTextFont(String familyName, float fontSize, com.spire.barcode.publics.drawing.FontStyle style)

Spire.OCR for Java

Category ID Description
New feature - Adds the ConfigureOptions class and new method ConfigureDependencies(ConfigureOptions configureOptions), which supports configuring OCR models, languages, and dependency libraries.
import com.spire.ocr.*;
import java.awt.geom.Rectangle2D;

public class OCRTest {
    public static void main(String[] args) throws Exception{
        OcrScanner scanner = new OcrScanner();
        ConfigureOptions configureOptions = new ConfigureOptions("D:\\LanguageModel", "English");
        String dependencies = "dependencies/";
        configureOptions.setLibPath(dependencies);
        scanner.ConfigureDependencies(configureOptions);
        String imageFile = "Sample.png";
        scanner. scan(imageFile);
        String scannedText=scanner.getText().toString();

        StringBuilder stringBuilder=new StringBuilder();
        for(IOCRTextBlock blockItem :scanner.getText().getBlocks()){
            Rectangle2D rectangle2D=blockItem.getBox();
            stringBuilder.append(blockItem.getText() +","+ "X"+ rectangle2D.getX()+"; Y:"+rectangle2D.getY()+ "; Width:"+ rectangle2D.getWidth()+ "; Height:"+ rectangle2D.getHeight());
        }
    }
}