We're pleased to announce the release of Spire.Doc for Java 14.1.0. This version optimizes methods related to list styles, supports creating/retrieving/deleting picture bullets, comparing two ListLevel objects, and creating single-level as well as multi-level lists from built-in templates. Additionally, several issues that occurred when converting Word to PDF and MHT to PDF have also been successfully fixed. More details are listed below.
Here is a list of changes made in this release
| Category | ID | Description |
| Optimization | - | Deprecated the Document.getListStyles() property, replaced it with Document.getListReferences(). |
| Optimization | - | Removed the public constructors of ListStyle. Added StyleCollection.add(ListType listType, string name) to create a ListStyle.
ListStyle listStyle = document.getStyles().add(ListType.Numbered, "levelstyle");
listStyle.isCustomStyle(true);
ListLevelCollection levels = listStyle.getListRef().getLevels();
levels.get(0).setPatternType(ListPatternType.Arabic);
levels.get(0).setStartAt(1);
levels.get(0).getCharacterFormat().setFontName("Trebuchet MS");
|
| Optimization | - | Updated the method for applying a ListStyle to a paragraph.
paragraph.getListFormat().applyStyle(ListStyle listStyle); paragraph.getListFormat().setListLevelNumber(int leverNumber) or paragraph.getListFormat().applyListRef(ListDefinitionReference list, int leverNumber); |
| Optimization | - | Removed the ListFormat.getCurrentListStyle() method, replaced it with ListFormat.getCurrentListRef(). |
| New feature | - | Added the add(ListTemplate template) method to ListCollection to create multi-level lists from built-in templates.
Document document = new Document();
Section sec = document.addSection();
Paragraph paragraph = sec.addParagraph();
// Create default bullet list template
ListTemplate template = ListTemplate.Bullet_Default;
ListDefinitionReference listRef = document.getListReferences().add(template);
// Create default numbered list template
ListTemplate template1 = ListTemplate.Number_Default;
listRef = document.getListReferences().add(template1);
listRef.getLevels().get(2).setStartAt(4);// Set the third level to start at number 4
// Add paragraph and apply numbered list style (level 2)
paragraph = sec.addParagraph();
paragraph.appendText("List Item 1");
// Apply level 2 (index starts at 0; 1 means the second level)
paragraph.getListFormat().applyListRef(listRef, 1);
paragraph = sec.addParagraph();
paragraph.appendText("List Item 2");
// Apply level 3
paragraph.getListFormat().applyListRef(listRef, 2);
paragraph = sec.addParagraph();
paragraph.appendText("List Item 3");
// Apply level 2
paragraph.getListFormat().applyListRef(listRef, 1);
paragraph = sec.addParagraph();
paragraph.appendText("List Item 4");
// Apply level 3
paragraph.getListFormat().applyListRef(listRef, 2);
document.saveToFile(outputFile, FileFormat.Docx);
document.close();
|
| New feature | - | Added the addSingleLevelList(ListTemplate listTemplate) method to ListCollection for quickly creating single-level lists.
Document document = new Document();
Section sec = document.addSection();
Paragraph paragraph = sec.addParagraph();
// Create Arabic numeral numbered list template (e.g., "1.", "2.", ...)
ListTemplate template = ListTemplate.Number_Arabic_Dot;
// Use addSingleLevelList to create a single-level list reference
ListDefinitionReference listRef = document.getListReferences().addSingleLevelList(template);
int levelcount = listRef.getLevels().getCount();//Check level count
boolean res=listRef.isMultiLevel();
// Add first list item
paragraph = sec.addParagraph();
paragraph.appendText("List Item 1");
paragraph.getListFormat().applyListRef(listRef, 0);
paragraph = sec.addParagraph();
paragraph.appendText("List Item 2");
paragraph.getListFormat().applyListRef(listRef, 0);
document.saveToFile(outputFile, FileFormat.Docx);
document.close();
|
| New feature | - | Added the ListLevel.equals(ListLevel level) method to compare whether two ListLevel objects are equal. |
| New feature | - | Added methods for creating, retrieving, and deleting picture bullets.
Document document = new Document();
Section sec = document.addSection();
Paragraph paragraph = sec.addParagraph();
// Create custom bulleted list style
ListStyle listStyle = document.getStyles().add(ListType.Bulleted, "bulletList");
// Get level configurations of this list style
ListLevelCollection Levels = listStyle.getListRef().getLevels();
// Set picture bullet for level 1
Levels.get(0).createPictureBullet();
Levels.get(0).getPictureBullet().loadImage(imag_Path_1);
// Set picture bullet for level 2
Levels.get(1).createPictureBullet();
Levels.get(1).getPictureBullet().loadImage(imag_Path_2);
// Add first list item
paragraph = sec.addParagraph();
paragraph.appendText("List Item 1");
paragraph.getListFormat().applyStyle(listStyle);
// Add second list item
paragraph = sec.addParagraph();
paragraph.appendText("List Item 1.1");
paragraph.getListFormat().applyStyle(listStyle);
paragraph.getListFormat().setListLevelNumber(1);
// Delete picture bullet for level 1
Levels.get(0).deletePictureBullet();
document.saveToFile(outputFile, FileFormat.Docx);
document.close();
|
| Bug | SPIREDOC-10843 | Fixed an issue where the application hung when processing a structured document. |
| Bug | SPIREDOC-11439 | Fixed an issue where the comparison of the table of contents failed. |
| Bug | SPIREDOC-11532 | Fixed an issue where the application hung when converting Word to PDF. |
| Bug | SPIREDOC-11605 SPIREDOC-11712 | Fixed an issue where the table layout was incorrect when converting Word to PDF. |
| Bug | SPIREDOC-11629 | Fixed an issue where text positioning was incorrect when converting Word to PDF. |
| Bug | SPIREDOC-11699 | Fixed an issue where text line wrapping was incorrect when converting Word to PDF while following WPS rules. |
| Bug | SPIREDOC-11709 | Fixed an issue where the application hung when converting MHT to PDF. |
| Bug | SPIREDOC-11741 | Fixed an issue that Avira Free Security Suite falsely detected a virus in spire.doc.jar. |
Click the link below to download Spire.Doc for Java 14.1.0: