We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

NUMPAGES in TextBox in Table is not updated

Hi,

I created document with section from other file. This section contains IF field with Textbox in Table in result. Probably this is similar situation to
https://forum.aspose.com/t/numpages-in-textbox-is-not-updated/231958

See the sample program and the document used to replicate the bug

var document = new Document();
var documentBuilder = new DocumentBuilder(document);
documentBuilder.InsertBreak(BreakType.PageBreak);

var template = new Document(@"Header.docx");
var importedSection = (Section)document.ImportNode(template.FirstSection, true);

document.AppendChild(importedSection);

foreach (var node in document.Sections)
{
    var sect = (Section)node;
    sect.PageSetup.RestartPageNumbering = true;
}

document.UpdateFields();
document.UpdatePageLayout();

document.Save(@"Test.docx");

Header3.docx (19.7 KB)
Test.docx (26.3 KB)

Could you take a look?
Thanks,
Monika

@acturisaspose As I can see the field in the header is updated properly and shows "1" as a result. Could you please clarify the problem.
There is the following condition { IF "{NUMPAGES}" > "1" "{PAGE}" "0" }. Since NUMPAGES is 3, the condition passes and the value of PAGE field is displayed. In the code you have specified PageSetup.RestartPageNumbering = true so for the first page of the section PAGE field shows "1".