Dear Team
We have created TOC in PDF document using following code. TOC is created successfully. However if we edit this newly created TOC in Adobe, we are not able to type few characters in TOC lines. We observed that we are not able to enter character that are not present in TOC. They are displayed as dots.
Also we observed that we are not able to edit heading “Table of Contents”. Please find attached input and output PDF files
public static void CreateTOCFromBookmarks(String FileIn, String FileOut)
{
Document doc = new Document(FileIn);
TocInfo tocInfo = new TocInfo();
Aspose.Pdf.Page tocPage = null;
TextFragment titleFrag = new TextFragment();
titleFrag = new TextFragment();
titleFrag.Text = "TABLE OF CONTENTS";
titleFrag.TextState.LineSpacing = 20;
titleFrag.TextState.FontSize = 12;
titleFrag.TextState.Font = FontRepository.FindFont("Times New Roman");
titleFrag.TextState.HorizontalAlignment = HorizontalAlignment.Center;
titleFrag.TextState.FontStyle = FontStyles.Bold;
tocPage = doc.Pages.Insert(1);
tocInfo.Title = titleFrag;
tocPage.TocInfo = tocInfo;
Aspose.Pdf.Heading heading2 = new Heading(1);
heading2.TextState.Font = FontRepository.FindFont("Times New Roman");
heading2.TextState.FontStyle = FontStyles.Regular;
heading2.TextState.FontSize = 12;
TextSegment segment2 = new TextSegment();
heading2.TocPage = tocPage;
segment2.Text = "Lorem ipsum dolor sit amet, consectetuer";
heading2.TextState.ForegroundColor = Color.Blue;
heading2.TextState.LineSpacing = 10;
heading2.DestinationPage = doc.Pages[2];
heading2.Top = doc.Pages[2].Rect.Height;
heading2.Segments.Add(segment2);
tocPage.Paragraphs.Add(heading2);
heading2 = new Heading(2);
heading2.TextState.Font = FontRepository.FindFont("Times New Roman");
heading2.TextState.FontStyle = FontStyles.Regular;
heading2.TextState.FontSize = 12;
segment2 = new TextSegment();
heading2.TocPage = tocPage;
segment2.Text = "In porttitor. Donec laoreet nonummy augue";
heading2.TextState.ForegroundColor = Color.Blue;
heading2.TextState.LineSpacing = 10;
heading2.DestinationPage = doc.Pages[2];
heading2.Top = doc.Pages[2].Rect.Height;
heading2.Segments.Add(segment2);
tocPage.Paragraphs.Add(heading2);
doc.Save(FileOut);
}
toc edit.zip (168.4 KB)