Free Support Forum - aspose.com

Can inserthtml interupt lists

Hi,

I am developing a solution that generates a document out of html content and try to use documentbuilder.listformat for it, but it seems that it only works with the first item and after i insert the html via documentbuilder.inserthtml it ignores the listindent and outdent commands

a little example is attached

Regards

Hi Simon,


Thanks for your inquiry. When you insert content by using Insert HTML, whole formatting is taken from HTML snippet and DocumentBuilder does not inherit formatting specified in HTML snippet. After inserting HTML via InsertHtml method, to achieve the desired results you need to set the correct node properties programmatically. Please visit the following link to learn more about Aspose.Words’ DOM.
http://www.aspose.com/docs/display/wordsnet/Object+Model+Overview

Best regards,

Hi,

Thanks for your reply. I looked at the link that you suggested and understand what you were pointing out.
But i dont manage to get the code to work. Could you plz try to correct my code?
Is it the wrong approach to insert the html into a new paragraph?

With builder
.MoveToSection(0)

.ListFormat.ApplyNumberDefault()
For Each Object As Object In List
Dim tmpp1 As New Paragraph(doc)
Dim tmpp2 As New Paragraph(doc)
sec2.Body.AppendChild(tmpp1)
sec2.Body.AppendChild(tmpp2)

.MoveTo(tmpp1)
.Writeln(Object.Title)
.MoveTo(tmpp2)
.InsertHtml(Object.HelpContent)
Next
.ListFormat.RemoveNumbers()
End With

Best regards,

Hi Simon,


Thanks for your inquiry. To ensure a timely and accurate response please supply us with the following information.

  • Please supply us with the HTML snippet you’re passing to InsertHtml method.
  • Please supply us with the Word document showing the undesired behavior
  • Please supply us with the target Word document showing the desired behavior. You can create target document using Microsoft Word. We just want to learn as to how you want your final document to be generated like.

As soon as you get these pieces of information to us we’ll start our investigation into your scenario and provide you code snippet.

Best regards,

Hi Awais,

Thanks for the fast reply.
Here is the Information you requested, note that there are 3 snippets in the snippetfile.
The title is generated from the objectname of my application so its not in the snippet file.
Just look at the snippet in my second posting.

Regards
Simon

Hi Simon,


Thanks for the additional information.

In your case, at the end of your code, you can simply iterate through all Paragraphs in your document that are formatted with Heading 1 style and specify list level numbers using DocumentBuilder. Please add the following code at the end:

Dim list As List = doc.Lists.Add(ListTemplate.NumberArabicDot)

For Each paragraph As Paragraph In doc.GetChildNodes(NodeType.Paragraph, True)

If paragraph.ParagraphFormat.StyleName = "Heading 1" Then

paragraph.ListFormat.List = list

paragraph.ListFormat.ListLevelNumber = 0

End If

Next paragraph


I hope, this helps.

Best regards,

Hi Awais,


Thank you very much for your help. This is exactly what i was looking for.
Your support is great!

Best regards