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"
.
Hi Alexey,
I’m not sure that we presented our issue clearly in the previous example - I’m attaching another one, that more closely shows what’s happening in our code. Basically what we have is a PageNo, nested within an iffield, within a textbox, within a table, within another table. we find that after importing it to the target document and running .updateFields the displayed value stays the same as it was in the source document. In the source document, the field is on second page, so the ‘2’ makes sense in that context, however after importing it to one page document and running updateFields and UpdatePageLayout I would expect it to display as ‘1’.
Thanks,
Tomek
PageFieldExample.zip (16.4 KB)
@acturisaspose Thank you for additional information.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): WORDSNET-25255
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
The issues you have found earlier (filed as WORDSNET-25255) have been fixed in this Aspose.Words for .NET 23.5 update also available on NuGet.