Hi,
Interesting situation. There are a number of sections. There is a business requirement that in a word document’s footer, there must be page numbering throughout entire document and each section. Furthermore, this situation get’s more complicated in that the first footer and second footer of a section can be different. In small documents, pretty fast; however, in large documents when the number of sections start to get large, the amount of time it takes to complete, increases.
To add page number for each sections is done as follow: builder.InserField(“PAGE \* MERGEFORMAT”);
For the entire document, the page numbering is accomplished by adding pages per section. Please see following code except:
foreach (string sect in sectionNames)
{
builder.MoveTo(field.Separator);
builder.Write(" + ");
builder.InsertField(“PAGEREF " + sect + " \# “0” \* MERGEFORMAT”);
}
Please see attached document for code being used (demo code.cs) as well as input document (demo of issue.docx) and output document (demo of issue2.docx).
If anyone has encountered a similar situation, did you have any ways to resolve the time faster? Thanks