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.

Hello @css and @fuchsia74 :vulcan_salute:

I apologize for the delayed response.

As my colleague mentioned:
The described behavior is a bug, and we are going to fix it in one of the next Document Server versions.

We will inform you when the solution is available.

hello @css and @fuchsia74, we have released Document Server 8.2 where we fixed the bug you reported earlier.

Please update the Document Server and check if the issue still persists.

Yes, works for me, thanks :smile:

3 Likes