How increase TableOfContents width(autofit it)?
axixa.docx (103.0 KB)
image.png (14.5 KB)
In this case, you can increase the width of Table of Contents (TOC Field) in Word DOCX document by using the following C# code of Aspose.Words for .NET API:
Document doc = new Document("C:\\Temp\\axixa.docx");
Style toc_Style = doc.Styles["TOC 2"];
toc_Style.ParagraphFormat.TabStops.Clear();
PageSetup page_Setup = doc.FirstSection.PageSetup;
double tab_Stop_Position = page_Setup.PageWidth - page_Setup.LeftMargin - page_Setup.RightMargin;
TabStop tab_Stop = new TabStop(tab_Stop_Position)
{
Alignment = TabAlignment.Right,
Leader = TabLeader.Dots
};
toc_Style.ParagraphFormat.TabStops.Add(tab_Stop);
doc.Save("C:\\Temp\\word.docx");