OfficeIMO
OfficeIMO copied to clipboard
update(lists): add symbol font size option
Issue: Currently there's no way to set font size of the list's numbering/bullet symbol.
int listItemFontSize = 14;
WordList wordList1 = document.AddList(WordListStyle.Headings111, false);
wordList1.AddItem("Text 1", 0)
.SetFontSize(listItemFontSize);
wordList1.AddItem("Text 2", 1);
wordList1.AddItem("Text 3", 2);
This PR adds the option to set the font size for numbering symbols in AddList()
.
// font size for both items and list's symbol
int listFontSize = 14;
WordList wordList1 = document.AddList(WordListStyle.Headings111, false, listFontSize);
wordList1.AddItem("Text 1", 0)
.SetFontSize(listFontSize);
wordList1.AddItem("Text 2", 1);
wordList1.AddItem("Text 3", 2);
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Would you be able to add some tests around it? Checking that expectations meets reality?
I'll take a look on the test code.
Seems like the initial WordListStyle
's NumberingSymbolRunProperties
is being applied to the whole wordlist of the same style.
~~Not sure where to check next. Got any lead?~~ Nevermind, I'm checking the markup now in open XML productivity tool.
// Heading1ai
{
int listFontSize = 32;
var wordList2 = doc.AddList(WordListStyle.Heading1ai, false, listFontSize);
foreach (var point in data.ListContent)
{
wordList2.AddItem($"{point}", 0)
.SetFontSize(listFontSize);
}
}
{
// font size on numbering symbol not applied
int listFontSize = 10;
var wordList2 = doc.AddList(WordListStyle.Heading1ai, false, listFontSize);
foreach (var point in data.ListContent)
{
wordList2.AddItem($"{point}", 0)
.SetFontSize(listFontSize);
}
}
// Bulleted
{
int listFontSize = 10;
var wordList2 = doc.AddList(WordListStyle.Bulleted, false, listFontSize);
foreach (var point in data.ListContent)
{
wordList2.AddItem($"{point}", 0)
.SetFontSize(listFontSize);
}
}
{
// font size on numbering symbol not applied
int listFontSize = 24;
var wordList2 = doc.AddList(WordListStyle.Bulleted, false, listFontSize);
foreach (var point in data.ListContent)
{
wordList2.AddItem($"{point}", 0)
.SetFontSize(listFontSize);
}
}
After merging with master
internal static void Example_BasicLists8(string folderPath, bool openWord) {
Console.WriteLine("[*] Creating standard document with lists - Document 8");
string filePath = System.IO.Path.Combine(folderPath, "Document with Lists11.docx");
using (WordDocument document = WordDocument.Create(filePath)) {
// add list and nest a list
WordList wordList1 = document.AddList(WordListStyle.Headings111, false, 15);
wordList1.AddItem("Text 1");
wordList1.AddItem("Text 1.1");
wordList1.AddItem("Text 1.2");
wordList1.AddItem("Text 1.3");
document.AddParagraph("Second List");
document.AddParagraph();
WordList wordList2 = document.AddList(WordListStyle.Headings111, false, 25);
wordList2.AddItem("Text 2");
wordList2.AddItem("Text 2.1");
wordList2.AddItem("Text 2.2");
wordList2.AddItem("Text 2.3");
wordList2.AddItem("Text 2.4");
document.AddParagraph("Third List");
document.AddParagraph();
WordList wordList3 = document.AddList(WordListStyle.Headings111, false, 50);
wordList3.AddItem("Text 3");
wordList3.AddItem("Text 3.1");
wordList3.AddItem("Text 3.2");
wordList3.AddItem("Text 3.3");
wordList3.AddItem("Text 3.4");
document.Save(openWord);
}
}
You're now ready to continue ;)
Althought it still would be valid what's the difference between using it how you are using and how Word uses Paragraph Properties for that.
awesome, thanks!