Hi,
Can you kindly guide me how to set the indentation i.e. the starting point of the bullet on a line, modify the space between the bullets and the text and set the line spacing between the lines having bullets using Aspose API’s. I have attached the screenshot of the aspose created word file ‘Aspose Output.png’ and a screenshot that is expected to be set in word file attached in ‘Expected Output.png’. I am providing the input html that was used to create the bullets as shown in the screenshots as follows:
- First Level
- Second Level
- Third level
- Fourth Level
- At First Level Again
- At Second Level Again
- At Third Level Again
- At Fourth Level Again
- First Level Returns
- Second Level Returns
- Third Level Returns
- Fourth Level Returns
Kindly guide me how can I get the expected output using aspose API.
Thanks,
Gaurang
Hi Gaurang,
Thanks for your inquiry. I suggest you please read the detail of List and ListLevel classes from here:
https://reference.aspose.com/words/java/com.aspose.words/list/
https://reference.aspose.com/words/java/com.aspose.words/listlevel/
Please use the ParagraphFormat.SpaceAfter property to get or set the amount of spacing (in points) after the paragraph.
Use the ListLevel.StartAt property to get or set the starting number for this list level.
Use the ListLevel.TabPosition property to get or set the tab position (in points) for the list level.
Please check the following code example for your kind reference. Hope this helps you. Please let us know if you have any more queries.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Create a numbered list based on one of the Microsoft Word list templates and
// apply it to the current paragraph in the document builder.
builder.getListFormat().setList(doc.getLists().add(ListTemplate.NUMBER_ARABIC_DOT));
// There are 9 levels in this list, lets try them all.
for (int i = 0; i <9; i++)
{
builder.getListFormat().setListLevelNumber(i);
builder.writeln("Level " + i);
}
// Create a bulleted list based on one of the Microsoft Word list templates
// and apply it to the current paragraph in the document builder.
builder.getListFormat().setList(doc.getLists().add(ListTemplate.BULLET_DIAMONDS));
// There are 9 levels in this list, lets try them all.
for (int i = 0; i <9; i++)
{
builder.getListFormat().setListLevelNumber(i);
builder.writeln("Level " + i);
}
// This is a way to stop list formatting.
builder.getListFormat().setList(null);
builder.getDocument().save(MyDir + "Lists.SpecifyListLevel Out.doc");
Hi Tahir,
Thank you for your reply. Can you kindly let me know how I can modify/set the space between a bullet and start of the text (hanging).
Thanks,
Gaurang.
Hi Gaurang,
Thanks for your inquiry. Please use the ParagraphFormat.setFirstLineIndent method to achieve your requirement. Note that ParagraphFormat.setFirstLineIndent method sets the value (in points) for a first line or hanging indent. Use a positive value to set a first-line indent, and use a negative value to set a hanging indent.
Please let us know if you have any more queries.