We're pleased to announce the release of Spire.Doc 13.8.1. This version supports comparing whether two list levels are consistent and setting or deleting the picture bullet. Besides, it has also made some adjustments to the properties and methods related to the lists in Word. More details are listed below.
Here is a list of changes made in this release
| New feature | - | Added 'ListLevel.Equals' to compare whether two ListLevels are consistent.
// Create a new Document object. Document document = new Document(); //Create list style 1 ListStyle listStyle_1 = document.Styles.Add(ListType.Bulleted, "bulletList"); ListLevelCollection Levels_1 = listStyle_1.ListRef.Levels; ListLevel L0 = Levels_1[0]; ListLevel L1 = Levels_1[1]; ListLevel L2 = Levels_1[2]; ListStyle listStyle_2 = document.Styles.Add(ListType.Bulleted, "bulletList"); ListLevelCollection Levels_2 = listStyle_2.ListRef.Levels; ListLevel l0 = Levels_2[0]; ListLevel l1 = Levels_2[1]; ListLevel l2 = Levels_2[2]; //Create list style 1 L0.ParagraphFormat.LineSpacing = 10 * 1.5f; L1.CharacterFormat.FontSize = 9; L1.IsLegalStyleNumbering = true; L1.PatternType = ListPatternType.Arabic; L1.FollowCharacter = FollowCharacterType.Nothing; L1.BulletCharacter = "\x006e"; L1.NumberAlignment = ListNumberAlignment.Left; L1.NumberPosition = -10; L1.TabSpaceAfter = 0.5f; L1.TextPosition = 0.5f; L1.StartAt = 4; L1.NumberSufix = "Chapter"; L1.NumberPrefix = "No."; L1.NoRestartByHigher = false; L1.UsePrevLevelPattern = false; L2.CharacterFormat.FontName = "Arial"; // Create list style 2 l0.ParagraphFormat.LineSpacing = 10 * 1.5f; l1.CharacterFormat.FontSize = 9; l1.IsLegalStyleNumbering = true; l1.PatternType = ListPatternType.Arabic; l1.FollowCharacter = FollowCharacterType.Nothing; l1.BulletCharacter = "\x006e"; l1.NumberAlignment = ListNumberAlignment.Left; l1.NumberPosition = -10; l1.TabSpaceAfter = 0.5f; l1.TextPosition = 0.5f; l1.StartAt = 4; l1.NumberSufix = "Chapter"; l1.NumberPrefix = "No."; l1.NoRestartByHigher = false; l1.UsePrevLevelPattern = false; l1.CreatePictureBullet(); l2.CharacterFormat.FontName = "Arial"; //Add 'ListLevel.Equals' to compare whether two ListLevels are consistent. bool r0 = L0.Equals(l0); bool r1 = L1.Equals(l1); bool r2 = L2.Equals(l2); |
| New feature | - | Supported setting or deleting the picture bullet.
// Create a new Document object.
Document document = new Document();
//Add a section
Section sec = document.AddSection();
Spire.Doc.Documents.Paragraph paragraph = sec.AddParagraph();
//Create list style
ListStyle listStyle = document.Styles.Add(ListType.Bulleted, "bulletList");
ListLevelCollection Levels = listStyle.ListRef.Levels;
Levels[0].CreatePictureBullet();
Levels[0].PictureBullet.LoadImage(@"logo.jpg");
Levels[1].CreatePictureBullet();
Levels[1].PictureBullet.LoadImage(@"py.jpg");
//Add paragraph and apply the list style
paragraph = sec.AddParagraph();
paragraph.AppendText("List Item 1");
paragraph.ListFormat.ApplyStyle(listStyle);
paragraph = sec.AddParagraph();
paragraph.AppendText("List Item 1.1");
paragraph.ListFormat.ApplyStyle(listStyle);
paragraph.ListFormat.ListLevelNumber = 1;
//DeletePictureBullet
Levels[0].DeletePictureBullet();
//Save doc file.
document.SaveToFile(@"out.docx", FileFormat.Docx);
document.Close();
|
| Optimization | - | Deprecated the “Document.ListStyles” and replaced it with “Document.ListReferences”. Added new methods in “Document.ListReferences” to create ListDefinitionReference classes.
// Create a new Document object.
Document document = new Document();
//Add a section
Section sec = document.AddSection();
Spire.Doc.Documents.Paragraph paragraph = sec.AddParagraph();
//Create listTemplate1
ListTemplate template = ListTemplate.BulletDefault;
ListDefinitionReference listRef = document.ListReferences.Add(template);
//Create listTemplate2
ListTemplate template1 = ListTemplate.NumberDefault;
ListDefinitionReference listRef1 = document.ListReferences.Add(template1);
listRef1.Levels[2].StartAt = 4;
int levelcount = listRef.Levels.Count;
//Add paragraph and apply the list style
paragraph = sec.AddParagraph();
paragraph.AppendText("List Item 1");
paragraph.ListFormat.ApplyListRef(listRef, 1);
paragraph = sec.AddParagraph();
paragraph.AppendText("List Item 2");
paragraph.ListFormat.ApplyListRef(listRef, 2);
//Add paragraph and apply the list style
paragraph = sec.AddParagraph();
paragraph.AppendText("List Item 3");
paragraph.ListFormat.ApplyListRef(listRef1, 1);
paragraph = sec.AddParagraph();
paragraph.AppendText("List Item 4");
paragraph.ListFormat.ApplyListRef(listRef1, 2);
//Save doc file.
document.SaveToFile("out.docx", FileFormat.Docx);
document.Close();
|
| Optimization | - | The public constructor for “ListStyle” has been removed. “ListStyle” objects are now managed within the “Document.Styles” collection and should be created using the “StyleCollection.Add(ListType listType, string name)” method.
ListStyle listStyle = document.Styles.Add(ListType.Numbered, "levelstyle"); listStyle.IsCustomStyle = true; listStyle.CharacterFormat.FontName = "Trebuchet MS"; ListLevelCollection levels = listStyle.ListRef.Levels; levels[0].PatternType = ListPatternType.Arabic; levels[0].StartAt = 1; levels[0].CharacterFormat.FontName = "Trebuchet MS"; |
| Optimization | - | Changed to apply the list style using "ListFormat.AppleStyle" or "ListFormat.AppleListRef(ListDefinitionReference list, int leverNode)" method. |
| Optimization | - | Changed the property “ListFormat.CurrentListStyle” to “ListFormat.CurrentListRef”. |
| Optimization | - | Removed “ListFormat.IsRistNumbering” and “ListFormat.CustomStyleName”. |
| Optimization | - | Changed to set the List “starting number” using the following method.
ListStyle numberList2 = document.Styles.Add(ListType.Numbered, "Numbered2"); ListLevelCollection Levels = numberList2.ListRef.Levels; Levels[0].StartAt = 10; |
Click the link to download Spire.Doc 13.8.1:
More information of Spire.Doc new release or hotfix: