We have an issue with table of contents alignment when that ToC was generated using the aspose words API.
Please see the 2 attached documents. They are identical aside from the the Font used in Heading 1.
We have created the Table of Contents using the T flag of the field code to supply a list of style that should be parsed to create the table of contents. We then use the Aspose API to change the fonts of the runs inside the table of contents in order to style it as this cannot otherwise be done via the API.
You will see that in the first document the table of contents is properly aligned, however in the second document when the table of contents gets to #10 the alignment changes which looks incorrect.
From our investigation we have found that if the Heading 1s were one of the following fonts then the ToC will be aligned, however if they were anything else then the ToC will not align properly.
Arial Black, Courier New, Verdana.
We’re finding this very confusing as regardless of the font used in the Heading 1s the table of contents will be set as Times New Roman (before we change the font), we’re struggling to understand why the Heading 1 font is having any effect on alignment of the Table of Contents. We have tried several different methods to re-align the Table of Contents using the API but have not had any success with this.
Please do let us know if there is something that we can do in order to align the Table of Contents consistently, as the current behaviour with different alignments for different fonts is causing problems. aspose_toc_alignment.zip (40.7 KB)