Problems with insertHtml with html that contains lists

Hi,
I’m trying to use insertHtml with html that contains ordered and unordered lists with sublists such as the html in the attached file.
If you change the attached file’s extension to html and open it in IE or in MS Word the lists are displayed exactly the way they should.
However, If I use insertHtml then there are several problems:

  • Bullets/Numbers appear left to where text lines begin.
  • The Bullets/Numbers of the sublists are not indented
  • In Ordered lists, the numbers of the sublists are turned into a.,b.,c and i.,ii,iii, etc.

How can I get the lists in my html to be displayed in the same way it’s displayed in IE?
Thanks in advance,
Itai

Hi

Thank you for reporting this problem to us. I managed to reproduce the problems on my side. Your request has been linked to the appropriate issues. You will be notified as soon as it is resolved.
It seems the problem with bullets position occurs because you specified negative left margin of list items. If remove negative left margin position of bullets is correct.
Best regards.

Thanks for the quick reply.
Regarding the suggested workaround for getting the right position of bullets, I get the html from another 3rd party component and I don’t want to start parsing it. It would be great if by using your API I’ll be able to insert html into my document and have it displayed in the same way as in IE.
Perhaps you can suggest some code snippet to correct the displaying of lists.
Thanks,
Itai

Hi

Thanks for your inquiry. I think, you can try post-processing of your document. You can try playing with ListLevel.NumberPosition, ListLevel.TabPosition, ListLevel.TextPosition to configure each level of your list. Please see the following link for more information:
https://reference.aspose.com/words/net/aspose.words.lists/listlevel/
Also, I think, the information provide in the following thread could be useful for you.
https://forum.aspose.com/t/91871
Best regards.

Hello Itai!
Thank you for your patience.
I have addressed your case and have some considerations. That’s not a good idea to indent list items with margin-left CSS attribute. I expect it’s intended to get some predictable layout by tuning those margins. But in browsers results won’t be so predictable. You can try the following sample:
Default list

  • 111
  • 222
  • 333
  • 444

List with altered item indents

  • 111
  • 222
  • 333
  • 444

By default, browser (say Internet Explorer) indents list items by some distance even if they don’t have margin-left. When margin-left is specified, its value is added to that default distance. There is a big difference from normal, non-list paragraphs such as p, h1h6. Non-list paragraphs also have some default indents in browsers. But if margin-left is given it is not added, it replaces the default. From this we conclude a rule: Avoid using native HTML lists (ol, ul, li) if layout is so important for you. It’s better to convert lists to ordinary paragraphs, apply table-driven design or whatever else.
I see that you acquire HTML documents from some third party. So it’s difficult to redesign them. You can try pieces of advice from my colleague. Also technique automatically replacing lists with paragraphs may be helpful. See the code in this discussion:
https://forum.aspose.com/t/106128
Experimenting with Aspose.Words version 8.2.0 (the latest) I haven’t got completely unindented list items. You wrote that list labels of the sublists are not indented. They are still indented after roundtrip but maybe a bit differently from what you expected. Another issue not mentioned in the first post is the difference in line spacing. I mean larger vertical spacing at the start of every list. It is also known and I have linked the thread to the appropriate change request.
Please try the latest version of Aspose.Words and clarify what issues related to indentation are still there.
Aspose.Words 8.2.0:
https://releases.aspose.com/words/net
Regards,

The issues you have found earlier (filed as 3296) have been fixed in this update.

The issues you have found earlier (filed as WORDSNET-3270) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.

The issues you have found earlier (filed as WORDSNET-2104) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(11)