We're pleased to announce the release of Spire.Office for Java 10.10.0. In this version, the Spire.Doc for Java supports retrieving style change revisions. Spire.PDF for Java supports setting column width for PdfTable. Spire.Presentation for Java supports converting Markdown to PPTX. In addition, many known issues that occurred when converting and processing Word/ Excel/ PDF/PowerPoint files have been successfully fixed. More details are listed below.
Click the link to download Spire.Office for Java 10.10.0:
Here is a list of changes made in this release
Spire.Doc for Java
| Category | ID | Description |
| New feature | SPIREDOC-9691 SPIREDOC-8447 | Added support for accepting or rejecting partial revisions.
Workbook workbook = new Workbook();
// Get the first worksheet from the workbook
Worksheet sheet = workbook.getWorksheets().get(0);
// Set the value of cell range A1 to "&=Array"
sheet.getCellRange("A1").setValue("&=Array");
// Add a parameter named "Array" with an array of strings as its value
workbook.getMarkerDesigner().addArray("Array", new String[] { "Spire.Xls", "Spire.Doc", "Spire.PDF", "Spire.Presentation", "Spire.Email" });
// Apply the marker design to the workbook
workbook.getMarkerDesigner().apply();
// Calculate all the values in the workbook
workbook.calculateAllValue();
// Auto-fit the rows and columns in the allocated range of the worksheet
sheet.getAllocatedRange().autoFitRows();
sheet.getAllocatedRange().autoFitColumns();
// Save the workbook to the specified file path using Excel 2013 format
workbook.saveToFile(outputFile, ExcelVersion.Version2013);
// Clean up and release resources used by the workbook
workbook.dispose();
|
| New feature | SPIREDOC-10632 SPIREDOC-11261 | Added support for retrieving style change revisions.
Document document = ConvertUtil.GetNewEngineDocument();
document.loadFromFile(inputFile);
RevisionInfoCollection revisionInfoCollection= document.getRevisionInfos();
for (RevisionInfo revisionInfo : (java.lang.Iterable)revisionInfoCollection) {
if(revisionInfo.getRevisionType()==RevisionType.Format_Change){
if(revisionInfo.getOwnerObject() instanceof TextRange){
TextRange range = (TextRange)revisionInfo.getOwnerObject();
TestUtil.writeAllText(outputFile,"TextRange:"+range.getText()+"\r\n");
document.setRevisionsView(RevisionsView.Original);
TestUtil.writeAllText(outputFile,"Original bold:"+range.getCharacterFormat().getBold()+"\r\n");
document.setRevisionsView(RevisionsView.Final);
TestUtil.writeAllText(outputFile,"Final bold:"+range.getCharacterFormat().getBold()+"\r\n");
}
}
}
document.close();
|
| New feature | SPIREDOC-11303 | Added support for tracking revision records for styles.
Document document = new Document();
document.loadFromFile("test.docx");
document.startTrackRevisions("e-iceblue");
for (int i=0; i<document.getSections().get(0).getParagraphs().get(0).getChildObjects().getCount();i++)
{
if (document.getSections().get(0).getParagraphs().get(0).getChildObjects().get(i).getDocumentObjectType()== DocumentObjectType.Text_Range)
{
TextRange tr = (TextRange) document.getSections().get(0).getParagraphs().get(0).getChildObjects().get(i);
tr.getCharacterFormat().setTextColor(Color.RED);
tr.getCharacterFormat().setFontSize(28);
tr.getCharacterFormat().setBold(true);
}
}
document.getSections().get(0).getParagraphs().get(1).appendText("aaa");
document.stopTrackRevisions();
document.saveToFile("test-out.docx");
|
| New feature | SPIREDOC-11313 | Added support for setting the number of characters per line in the document grid.
sec.getPageSetup().setGridType(GridPitchType.Chars_And_Line); sec.getPageSetup().setCharactersPerLine(30); |
| Bug | SPIREDOC-9775 | Fixed the issue where revision acceptance behavior was incorrect. |
| Bug | SPIREDOC-10561 SPIREDOC-11399 SPIREDOC-11405 SPIREDOC-11476 SPIREDOC-11481 SPIREDOC-11518 SPIREDOC-11530 SPIREDOC-11569 SPIREDOC-11585 | Fixed the issues where rendering effect was incorrect when converting Word to PDF. |
| Bug | SPIREDOC-10635 | Fixed the issue that highlight colors could not be retrieved when AcceptChanges() is not called. |
| Bug | SPIREDOC-10995 | Fixed the issue where errors occurred when setting table styles. |
| Bug | SPIREDOC-11433 | Fixed the issue that the table of contents updated incorrectly. |
| Bug | SPIREDOC-11511 SPIREDOC-11599 | Fixed the issues where rendering was incorrect when converting HTML to Word. |
| Bug | SPIREDOC-11519 | Fixed the issue where text was garbled when converting MHT files to DOCX. |
| Bug | SPIREDOC-11520 | Fixed the issue that "IllegalArgumentException" was thrown when loading documents. |
| Bug | SPIREDOC-11525 | Fixed the issue that "NullPointerException" was thrown when loading documents. |
| Bug | SPIREDOC-11531 | Fixed the issue where behavior was incorrect when removing content controls. |
| Bug | SPIREDOC-11551 | Fixed the issue that bookmarks returned empty. |
| Bug | SPIREDOC-11560 | Fixed the issue that selected checkboxes failed to remain checked. |
| Bug | SPIREDOC-11563 | Fixed the issue that content regions were non-editable after accepting revisions. |
| Bug | SPIREDOC-11572 | Fixed the issue where image content was lost when saving documents to WPS format. |
| Bug | SPIREDOC-11589 | Fixed issue with "NullPointerException" being thrown when using replaceBookmarkContent. |
| Bug | SPIREDOC-11597 | Fixed the issue that replacement behavior was incorrect. |
| Bug | SPIREDOC-11600 | Fixed the issue that "Cannot remove because there is no parent" exception was thrown when using StructureDocumentTagCell.removeSelfOnly. |
Spire.XLS for Java
| Category | ID | Description |
| Optimization | SPIREXLS-5921 | Optimized memory consumption when loading Excel documents. |
| Bug | SPIREXLS-5185 | Fixed the issue where retrieving checkboxes failed. |
| Bug | SPIREXLS-5913 | Fixed the issue where the application hung when loading Excel files under a configured JVM maximum memory limit. |
| Bug | SPIREXLS-5930 | Fixed the issue where an out-of-memory error occurred when converting Excel to PDF. |
| Bug | SPIREXLS-5954 | Fixed the issue where formatting was inconsistent when copying worksheets. |
| Bug | SPIREXLS-5956 | Fixed the issue where an "error in set print area" exception was thrown when saving Excel files. |
| Bug | SPIREXLS-5957 | Fixed the issue where an "Input string was not in the correct format" exception was thrown when loading Excel files. |
Spire.PDF for Java
| Category | ID | Description |
| New feature | SPIREPDF-5995 | Added support for setting column width for PdfTable.
// Create PDF document
PdfDocument doc = new PdfDocument();
// Set margins
PdfUnitConvertor unitCvtr = new PdfUnitConvertor();
PdfMargins margin = new PdfMargins();
margin.setTop(unitCvtr.convertUnits(2.54f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point));
margin.setBottom(margin.getTop());
margin.setLeft(unitCvtr.convertUnits(3.17f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point));
margin.setRight(margin.getLeft());
// Add a page
PdfPageBase page = doc.getPages().add(PdfPageSize.A4, margin);
// Add table
PdfTable table = new PdfTable();
PdfSolidBrush brush = new PdfSolidBrush(new PdfRGBColor(Color.black));
table.getStyle().setBorderPen(new PdfPen(brush, 0.5f));
table.getStyle().getHeaderStyle().setStringFormat(new PdfStringFormat(PdfTextAlignment.Center));
table.getStyle().setHeaderSource(PdfHeaderSource.Rows);
table.getStyle().setHeaderRowCount(1);
table.getStyle().setShowHeader(true);
table.getStyle().setCellPadding(2);
table.getStyle().setHeaderSource(PdfHeaderSource.Rows);
table.getStyle().setHeaderRowCount(1);
table.getStyle().setShowHeader(true);
// Set header font and style
PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("SimSun", Font.PLAIN, 12));
table.getStyle().getHeaderStyle().setFont(font);
table.getStyle().getHeaderStyle().setBackgroundBrush(PdfBrushes.getCadetBlue());
PdfTrueTypeFont fontBody = new PdfTrueTypeFont(new Font("SimSun", Font.PLAIN, 10));
// Set even row font
table.getStyle().getDefaultStyle().setFont(fontBody);
// Set odd row font
table.getStyle().getAlternateStyle().setFont(fontBody);
// false: distribute by total width proportion, true: use set column width
table.getStyle().isFixWidth(true);
// Define data
String[] data = {"1;2;3;4;5",
"A1;B1;1,391,190,000;18.2%; ",
"A1;B1;126,490,000;1.66%; ",
"A1;B1;65,648,054;0.86%; ",
"A1;B1;82,665,600;1.08%; ",
"A1;B1;37,119,000;0.49%; ",
"A1;B1;327,216,000;4.29%; "
};
String[][] dataSource = new String[data.length][];
for (int i = 0; i < data.length; i++) {
dataSource[i] = data[i].split("[;]", -1);
}
table.setDataSource(dataSource);
for(int i = 0; i < table.getColumns().getCount(); i++)
{
PdfColumn column = table.getColumns().get(i);
column.setWidth(50);
column.setStringFormat(new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle));
}
// Add table to page
table.draw(page, new Point2D.Float(0, 50));
// Save document
doc.saveToFile("addTable.pdf", FileFormat.PDF);
|
Spire.Presentation for Java
| Category | ID | Description |
| New feature | - | Added Support for converting Markdown to PPTX files.
Presentation pt = new Presentation();
pt.loadFromFile("input.md", FileFormat.Markdown);
pt.saveToFile("output.pptx", FileFormat.PPTX_2013);
pt.dispose();
|
| New feature | - | Added the AddFromSVGAsShape method to convert SVG into shapes.
Presentation ppt = new Presentation();
ppt.loadFromFile("input.pptx");
for (int i = 0; i < ppt.getSlides().getCount(); i++)
{
ppt.getSlides().get(i).getShapes().addFromSVGAsShapes("in.svg");
}
ppt.saveToFile("output.pptx", FileFormat.PPTX_2013);
ppt.dispose();
|
| Bug | SPIREPPT-2886 | Fixed the issue where added LaTeX formulas were rendered incorrectly. |
| Bug | SPIREPPT-2980 | Fixed the issue where the chart data label formatting was incorrect after converting PowerPoint files to PDF. |
| Bug | SPIREPPT-2981 | Fixed the issue where the text direction was incorrect after converting PowerPoint files to PDF. |
| Bug | SPIREPPT-3009 | Fixed the issue where adding a LaTeX formula (\square) caused a “NullPointerException”. |
Spire.Barcode for Java
| Category | ID | Description |
| Bug | SPIREBARCODE-273 | Fixed the issue where the application threw a "java.lang.OutOfMemoryError" when scanning an image. |
| Bug | SPIREBARCODE-276 | Fixed the issue of incorrect result data when scanning an image. |