Free Support Forum -

Right aligned page numbers in table of contents in HTML

When I save a document that has a table of contents to HTML, is there anyway to right align the page numbers? Word is able to accomplish this using extra periods in the HTML.

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for your inquiry.

TOC field in MS Word document contains tab characters delimiting headings and page numbers. These tabs can be filled as in your case. They can not be exported to HTML natively. There is no such a construction in HTML to export filled tabs so both MS Word and Aspose.Words have to simulate it.

You can see that MS Word inserts some number of periods in place of filled tabs when it exports TOC. How many periods to insert is a non-trivial question leading to rendering task, namely calculating size and position of document elements. In classic Aspose.Words "flow document" model it's impossible. Now we are working on the rendering engine also known as Aspose.Words.Viewer. So in the future we'll provide solutions for rendering-related tasks.

Note that building TOC or adding page numbers is meaningless for HTML format. HTML format is designed to represent one page (even if very long). Huge and complex content is usually split into several pages on the Web so you can navigate from one to another with hyperlinks. Just think about this. Do you really need TOC in HTML?

Best regards,