The page number is incorrect after the doc directory is generated

The page number is incorrect after the doc directory is generated

builder.CreateFile("docx");
var oDocument = Api.GetDocument();

var oSection = oDocument.GetFinalSection();
var oFooter = oSection.GetFooter("default", true);
oParagraph = oFooter.GetElement(0);
oParagraph.AddPageNumber();
oParagraph.SetJc("center");

var oNewDocumentStyle = oDocument.GetStyle("Heading 1");
var oParagraph = oDocument.GetElement(0);
oParagraph.SetStyle(oNewDocumentStyle);
oParagraph.AddText("Heading 1");

oNewDocumentStyle = oDocument.GetStyle("Heading 2");
oParagraph = Api.CreateParagraph();
oParagraph.SetStyle(oNewDocumentStyle);
oParagraph.AddText("Heading 2");
oDocument.Push(oParagraph);
oParagraph.AddPageBreak();

oNewDocumentStyle = oDocument.GetStyle("Heading 2");
oParagraph = Api.CreateParagraph();
oParagraph.SetStyle(oNewDocumentStyle);
oParagraph.AddText("Heading 3");
oDocument.Push(oParagraph);

var oTocPr = {"ShowPageNums": true, "RightAlgn": true, "LeaderType": "dot", "FormatAsLinks": true, "BuildFrom": {"OutlineLvls": 9}, "TocStyle": "standard"};
oDocument.AddTableOfContents(oTocPr);
oDocument.UpdateAllTOC(false);

builder.SaveFile("docx", "UpdateAllTOC.docx");
builder.CloseFile();


1 Like

hey @css
We are checking the situation.

This is most likely a bug… (Possible issues with updating the Table of Contents may exist.)
I will let you know when I get something.

How long will this take? Will you fix and update this bug?

We are checking the situation.
I will notify you when I have something to share.

"I’m encountering the same issue with ‘updateAllToc’ not working as expected. Has anyone found a solution or a workaround for this problem?

Hello @fuchsia74
We are checking the described scenario provided by topic starter. We will update this thread as soon as possible.