HTML Styles

Hi there,

We are trying to create table on content section in the word document dynamically and it seems that aspose engine just ignores the styles that we are specifying.

Just wondering if anyone else has also come across this issue and what would be the best possible solution ??

We want to display text as following:

ABC SECTION..........................................................................................1

We are currently using following HTML tags but it seems that it can’t render dotted lines.

<table border="1" width="95%">
   <td nowrap="1">
     Section Title
     <span style="border-bottom:1px dotted black; width:100%;">&nbsp;</span>
   <td width="35">100</td>

any suggestions, please let us know


Thanks for your request. Is it requirement of your application to use HTML? Actually, there is very simple way to achieve what you need without using HTML or Tables at all. Please see the following simple code:

DocumentBuilder builder = new DocumentBuilder();
// Remove all tabstops and add one right aligned tab.
// Calculate position of the tab.
double tabPosition = builder.PageSetup.PageWidth - builder.PageSetup.LeftMargin - builder.PageSetup.RightMargin;
builder.CurrentParagraph.ParagraphFormat.TabStops.Add(tabPosition, TabAlignment.Right, TabLeader.Dots);
// Insert text

Hope this helps.
Best regards.

Hi Alex,

Thanks for your response. Unfortunately yes my application needs to be in HTML as we are not just creating one table of content, we in fact have many sections within the document that are formatted to look like TOC.

Any other suggestions ?

Thanks for your help


Hi Sunny,

Thank you for additional information. Unfortunately, you cannot be 100% sure that HTML inserted into the document will look exactly as it looks in browsers. This is because:

  1. Aspose.Words is originally designed to work with Word documents formats, like DOC, DOCX, WordML, RTF etc. HTML is not Word format and it is difficult and sometimes impossible to map between HTML and Word features. These formats are very different internally.
  2. Aspose.Words does not support some HTML features, so you can lose some formatting of your HTML. Unfortunately, we do not have a list of HTML features supported upon HTML import. Currently we have only list of supported features for HTML export (saving to HTML). You can find it here:

Best regards.