I would like to manipulate the footer content on different page.
Hi there,
Document doc = new Document(MyDir + “SampleDoc.docx”);<o:p></o:p>
DocumentBuilder builder = new DocumentBuilder(doc);
HeaderFooter hf = doc.FirstSection.HeadersFooters[HeaderFooterType.FooterPrimary];
Node[] nodes = hf.ChildNodes.ToArray();
int childCount = hf.ChildNodes.Count;
Paragraph para = new Paragraph(doc);
hf.InsertBefore(para, hf.FirstChild);
builder.MoveTo(para);
// { IF "{PAGE}" = "{NUMPAGES}" "Content Visible on Last Page Only" "" }
Field field = builder.InsertField("IF \"", null);
builder.MoveTo(field.Start.NextSibling.NextSibling);
builder.InsertField("PAGE", null);
builder.Write("\" = \"");
builder.InsertField("NUMPAGES", null);
builder.Write("\" \"");
BookmarkStart bmStart = builder.StartBookmark("bm");
builder.Writeln();
builder.EndBookmark("bm");
builder.Write("\" \"\"");
Paragraph bmPara = bmStart.ParentNode as Paragraph;
foreach (Node node in nodes)
{
hf.InsertAfter(node, bmPara);
}
builder.MoveToDocumentEnd();
doc.UpdateFields();
doc.Save(MyDir + "17.5.docx");