First number in numbered list has formatting of previous paragraph

Hi,

When I create a list in a document, the list number seems to keep the formatting of the previous text I wrote. For example, if I just wrote some text in bold, then turned off bold, then made a numbered list, the “1.” at the beginning of the list would be bold. The code below produces the attached file, which demonstrates this bug.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.setBold(true);
builder.writeln(“Bold”);
builder.setBold(false);

builder.getListFormat().setList(doc.getLists().add(ListTemplate.NUMBER_DEFAULT));
builder.writeln(“1”);
builder.writeln(“2”);
builder.getListFormat().setList(null);

OoxmlSaveOptions saveOptions = new OoxmlSaveOptions(SaveFormat.DOCX);
saveOptions.setCompliance(OoxmlCompliance.ISO_29500_2008_TRANSITIONAL);
doc.save("/home/rickesco/Desktop/ListWeird.docx", saveOptions);

I’m using Aspose Words 13.8 and Word 2013.

Thanks,
Ricky

Hi Ricky,

Thanks for your inquiry. I have tested the scenario using latest version of Aspose.Words for Java 15.5.0 and have not found the shared issue. Please use Aspose.Words for Java 15.5.0 and let us know if you have any more queries.

I figured upgrading would fix it, but it’s nice to get the confirmation. I upgraded and now my problem is solved. Thank you!

Hi Ricky,

Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.