TableOfContents on second page

Is it possible to create a table of contents on the second page of docx file using docbuilder?
TableOfContents method puts the table of contents on the first page only.

Hello,
you can use the following method before the content that you’d like to move, it adds a page break: ONLYOFFICE Api Documentation - AddPageBreak
In particular, the following line -
oParagraph.AddPageBreak();

As far as I understand from practice, TableOfContents is applied not to a paragraph, but to a document, and accordingly does not move in the specified way. If this is not the case, can you provide an example of working code? Thank you.

Hello,
You can check the Document Builder scripts here: ONLYOFFICE Api Documentation - Try now
The table of contents is moved to the second page if you add a Page Break like this:

builder.CreateFile(“docx”);
var oDocument = Api.GetDocument();
var oNewDocumentStyle = oDocument.GetStyle(“Heading 1”);
var oParagraph = oDocument.GetElement(0);
oParagraph.SetStyle(oNewDocumentStyle);
oParagraph.AddText(“Heading 1”);
oParagraph.AddPageBreak();
oNewDocumentStyle = oDocument.GetStyle(“Heading 2”);
oParagraph = Api.CreateParagraph();
oParagraph.SetStyle(oNewDocumentStyle);
oParagraph.AddText(“Heading 2”);
oDocument.Push(oParagraph);
var oTocPr = {“ShowPageNums”: true, “RightAlgn”: true, “LeaderType”: “dot”, “FormatAsLinks”: true, “BuildFrom”: {“OutlineLvls”: 9}, “TocStyle”: “standard”};
oDocument.AddTableOfContents(oTocPr);
builder.SaveFile(“docx”, “AddTableOfContents.docx”);
builder.CloseFile();