Save document with Lisitng

Hi ,
I am using Aspose.words.Java .I used the below code to create paragraph list. If i save it as .DOCX , listing character ( '1' ) is shown correct . But when i saved it as .DOC, am not getting the list level character properly, it shows the like "%1.". please do help me .

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Paragraph para = builder.insertParagraph();
para.getListFormat().setList(doc.getLists().add(ListTemplate.NUMBER_DEFAULT));
para.getListFormat().getListLevel().setNumberFormat("%1.");//No i18n
builder.writeln("test");
doc.save("D:\\out.doc", SaveFormat.DOC);

Hi Anbu,

Thanks for your inquiry. The ListLevel.NumberFormat returns or sets the number format for the list level. Among normal text characters, the string can contain placeholder characters \x0000 to \x0008 representing the numbers from the corresponding list levels.

For example, the string “\x0000.\x0001)” will generate a list label that looks something like “1.5)”. The number “1” is the current number from the 1st list level, the number “5” is the current number from the 2nd list level.

You may use Document.UpdateListLabels to update list labels for all list items in the document. This method updates list label properties such as LabelValue and LabelString for each ListLabel object in the document.

Could you please share your expected output document here for our reference? We will then provide you more information on this along with code.

Hi ,

I have attached my document below . please do help me along with the code .

Hi Anbu,

Thanks
for sharing the document. Please use the following code example to get the required output and let us know if you have any more queries. Hope this helps you.


Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

// Create a list.

com.aspose.words.List list = doc.getLists().add(ListTemplate.NUMBER_DEFAULT);

builder.getListFormat().setList(list);

builder.getListFormat().getListLevel().setNumberFormat("\u0000.");

//ListLevel level1 = list.getListLevels().get(0);

//level1.setNumberFormat("\u0000.");

builder.writeln("One");

builder.writeln("Two");

builder.writeln("Three");

builder.getListFormat().removeNumbers();

doc.save(MyDir + "Out.doc");

doc.save(MyDir + "Out.docx");