What is the API for adding a catalog?
Thank you !
Spire.Doc.Section sec = doc.Sections[0];
Spire.Doc.Documents.Paragraph para = new Spire.Doc.Documents.Paragraph(doc);
sec.Paragraphs.Insert(0, para);
para.AppendTOC(1, 3);
caroline.zhang wrote:Hello,
Do you want to add a table of content? I am bit confused at this point of adding a catalog.
If so, please try the below code:
- Code: Select all
Spire.Doc.Section sec = doc.Sections[0];
Spire.Doc.Documents.Paragraph para = new Spire.Doc.Documents.Paragraph(doc);
sec.Paragraphs.Insert(0, para);
para.AppendTOC(1, 3);
If not, could you please elaborate your requirement to help us know it? Thank you.
Sincerely,
Caroline
E-iceblue support team
caroline.zhang wrote:Hi,
Thank you for reply.
Could you please provide your word file to help us for testing?
Thank you in advance.
Caroline
E-iceblue support team
Document doc = new Document();
doc.LoadFromFile("catalog.docx");
Section sec = doc.Sections[0];
Paragraph para = new Paragraph(doc);
sec.Paragraphs.Insert(0, para);
para.AppendTOC(2, 4);
doc.UpdateTableOfContents();
doc.SaveToFile("result.docx",FileFormat.Docx2013);
System.Diagnostics.Process.Start("result.docx");
caroline.zhang wrote:Hello,
Thank you for your file.
The below code for your reference.
- Code: Select all
Document doc = new Document();
doc.LoadFromFile("catalog.docx");
Section sec = doc.Sections[0];
Paragraph para = new Paragraph(doc);
sec.Paragraphs.Insert(0, para);
para.AppendTOC(2, 4);
doc.UpdateTableOfContents();
doc.SaveToFile("result.docx",FileFormat.Docx2013);
System.Diagnostics.Process.Start("result.docx");
Sincerely,
Caroline
E-iceblue support team
caroline.zhang wrote:Glad to help you.
If there is any question when using our products, welcome to feel free to ask us.
Sincerely,
Caroline
E-iceblue support team
Document doc = new Document();
doc.LoadFromFile("test.docx");
TableOfContent toc = doc.TOC;
var tocObject = toc.Owner.Owner.Owner;
tocObject.Owner.ChildObjects.Remove(tocObject);
doc.SaveToFile("sample.docx", FileFormat.Docx2013);
System.Diagnostics.Process.Start("sample.docx");
caroline.zhang wrote:Hello,
Please try the following solution:
- Code: Select all
Document doc = new Document();
doc.LoadFromFile("test.docx");
TableOfContent toc = doc.TOC;
var tocObject = toc.Owner.Owner.Owner;
tocObject.Owner.ChildObjects.Remove(tocObject);
doc.SaveToFile("sample.docx", FileFormat.Docx2013);
System.Diagnostics.Process.Start("sample.docx");
Sincerely,
Caroline
E-iceblue support team
TableOfContent toc = doc.TOC; //defines a field as table of content
var para = toc.Owner; //Gets Toc Paragraph in the doc
var con = para.Owner; //Gets SDTContent of toc paragraph
var tocObject = con.Owner; //Gets StructureDocumentTag of the content