We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Control of formatting of numbered list elements with InsertHtml?

I am trying to insert a fragment of HTML containing a numbered list. Despite the fact that I have set a font size of 12pts on every possible element I am still finding that 3 out of 4 list elements are displaying at the default paragraph style font size.

Any ideas as to anything I can do to avoid this?

  1. Industrial structure score

  2. Proportion of employment in Knowledge-driven sectors

  3. Industrial Structure indicators

  4. Industrial Structure indicators

Thanks for your request. It seems that I can’t reproduce this issue on my side. Please take a look the attached document. This is document I got using the following code.

string html = File.ReadAllText(@"Test034\test.txt");
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Could you please attach your document for testing?
Also I simplified your HTML and got the same result.

  • Industrial structure score
  • Proportion of employment in Knowledge-driven sectors
  • Industrial Structure indicators
  • Industrial Structure indicators

Best regards.

Hi Alexey,
Your sample does reproduce the issue. The numbers are displayed black and in New Roman.
The design I was trying to create had them blue and Arial

Thanks for your request. Now I see your problem. Maybe you can try using the following code as a workaround.

string html = File.ReadAllText(@"Test034\test.txt");
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Get paragraph (List item)
Paragraph par = builder.CurrentParagraph.PreviousSibling as Paragraph;
// Set formating of list.
par.ListFormat.ListLevel.Font.Name = "Arial";
par.ListFormat.ListLevel.Font.Size = 12;
par.ListFormat.ListLevel.Font.Color = Color.FromArgb(0, 62, 126);
// Save output document

I hope this could help you.
Best regards.

Thanks Alexey.
I am trying to avoid custom procedural programming as I am wanting to write a report builder that can take a declarative definition (including HTML fragments) and generate a report.
I ended up just hard coding the numbers rather than using li tags.
My suggestion in the other thread for firing an event as nodes are inserted along with the associated HTML fragment would have helped here as well as I could have written generic code to parse list style attributes not handled natively by Aspose.Words and set the ListFormat.ListLevel attributes there.

Thanks for your suggestion. I will consult with our developers. And maybe I will add this option as feature request to our defect database.
Best regards.

While some HTML here is “less than ideal” for example a list is inside a paragraph and a list inside a span (which really makes no sense both from HTML and from Aspose.Words point of view) it looks to me that Aspose.Words should import font size and font name correctly. So Alexey please log a defect and Viktor will look at it.
The way Aspose.Words HTML import works now - it does not support inheritance of CSS attributes therefore font-family will only be imported for spans (and other inline HTML elements). Setting font-family for ol and li will be ignored.
To workaround you can try “straightening out” your HTML to something like this:

  1. Test
  2. Test
  3. Test

And see if that works.

Hi Roman,

My original HTML was indeed a lot cleaner than the posted. I ended up adding extraneous elements in order to try and influence the styling of the word paragraphs that were created.

Strangely I found that I managed to get the number 2 in the list to appear styled but numbers 1,3 and 4 weren’t!

As far as I can see your solution will not style the numbers themselves?

Viktor will handle from here to check why only one number gets styled and whether they are supposed to get styled in the current code.
I can only add that HTML import in Aspose.Words will soon undergo a significant rework to include full CSS import support.

Hi Martin,
I have created new issue #4891 in our defect database. Please expect a reply before the next hotfix (within 2-3 weeks). We might just fix it by then or provide you more information.
Best regards.

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

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