Free Support Forum - aspose.com

Problem with multilevel lists

We have big issues with converting multilevel lists from HTML to Word. Currently, we have some strange space added after the numbers in our

  • elements, on the deeper levels of the list.

    I attached our resulting Word document below.

    Please take a look at our code:

    <pre style=“background-color: rgb(255, 255, 255); font-family: “Courier New”; font-size: 9.6pt;”>static void multiList(Document doc, ArrayList multiListIds, ArrayList singleListIds) throws Exception {
    List multiLevelParentList = null;
    for(Object p : doc.getChildNodes(NodeType.PARAGRAPH, true)) {
    Paragraph para = (Paragraph) p;
    if (para.isListItem()) {
    // do numbering style only for ol list
    if (para.getListFormat().getListLevel().getNumberStyle() == NumberStyle.ARABIC) {
    ListFormat listFormat = para.getListFormat();
    Integer listId = listFormat.getList().getListId();

    // set number position to 0 because too much tab space
    listFormat.getListLevel().setNumberPosition(-6);

    switch (listFormat.getListLevelNumber()) {
    case 1:
    // use multiLevelParentList as parent list for nested lists
    para.getListFormat().setList(multiLevelParentList);
    if (!multiListIds.contains(listId)) {
    multiListIds.add(listId);
    listFormat.getListLevel().setNumberFormat("\u0000.\u0001.");

    if (singleListIds.contains(listId)) {
    singleListIds.remove(listId);
    }
    }
    break;
    case 2:
    setListLevelFormat(multiListIds, singleListIds, listFormat, listId, \u0000.\u0001.\u0002.”, multiLevelParentList);
    break;
    case 3:
    setListLevelFormat(multiListIds, singleListIds, listFormat, listId, \u0000.\u0001.\u0002.\u0003.”, multiLevelParentList);
    break;
    case 4:
    setListLevelFormat(multiListIds, singleListIds, listFormat, listId, \u0000.\u0001.\u0002.\u0003.\u0004.”, multiLevelParentList);
    break;
    case 5:
    setListLevelFormat(multiListIds, singleListIds, listFormat, listId, \u0000.\u0001.\u0002.\u0003.\u0004.\u0005.”, multiLevelParentList);
    break;
    case 6:
    setListLevelFormat(multiListIds, singleListIds, listFormat, listId, \u0000.\u0001.\u0002.\u0003.\u0004.\u0005.\u0006.”, multiLevelParentList);
    break;
    case 7:
    setListLevelFormat(multiListIds, singleListIds, listFormat, listId, \u0000.\u0001.\u0002.\u0003.\u0004.\u0005.\u0006.\u0007.”, multiLevelParentList);
    break;
    default:
    if (!singleListIds.contains(listId) && !multiListIds.contains(listId)) {
    singleListIds.add(listId);
    }
    listFormat.getListLevel().setNumberFormat("\u0000.");
    // save first level list format to multiLevelParentList for all child!
    multiLevelParentList = para.getListFormat().getList();

    }
    }
    }
    }
    }<pre style=“background-color: rgb(255, 255, 255); font-family: “Courier New”; font-size: 9.6pt;”>
    <pre style=“background-color: rgb(255, 255, 255); font-family: “Courier New”; font-size: 9.6pt;”>As you can see, everything works fine on the 0 and 1st level of the list, but on the second level we have some unexpected spaces. <pre style=“background-color: rgb(255, 255, 255); font-family: “Courier New”; font-size: 9.6pt;”>It is very important and quite urgent for us to have this sorted out as soon as possible.<pre style=“background-color: rgb(255, 255, 255); font-family: “Courier New”; font-size: 9.6pt;”>
    <pre style=“background-color: rgb(255, 255, 255); font-family: “Courier New”; font-size: 9.6pt;”>Regards,<pre style=“background-color: rgb(255, 255, 255); font-family: “Courier New”; font-size: 9.6pt;”>Sofija Vojvodic<pre style=“background-color: rgb(255, 255, 255); font-family: “Courier New”; font-size: 9.6pt;”>
    <pre style=“background-color: rgb(255, 255, 255); font-family: “Courier New”; font-size: 9.6pt;”>
    <pre style=“background-color: rgb(255, 255, 255); font-family: “Courier New”; font-size: 9.6pt;”>
  • Hi Sofija,

    Thanks for your inquiry. To ensure a timely and accurate response, please attach the following resources here for testing:

    • Your input Html document
    • Please attach the output Word file that shows the desired behavior.
    • Please create a simple Java application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

    As soon as you get these pieces of information ready, we'll start investigation into your issue and provide you more information. Thanks for your cooperation.

    PS: To attach these resources, please zip them and Click 'Reply' button that will bring you to the 'reply page' and there at the bottom you can include any attachments with that post by clicking the 'Add/Update' button.