|124418||Jun 8,2016 01:42 PM UTC||Jun 10,2016 04:20 AM UTC||WinForms||3|
//Create new paragraph
WParagraph paragraph = new WParagraph(footer.Document);
//To get the total number of pages excluding first page, the field should be in below syntax
//Insert the formula field to the paragraph
WField formulafield = paragraph.AppendField("Formula", FieldType.FieldExpression) as WField;
formulafield.FieldCode = "=";
//Get the index of the formula field in the paragraph items.
int fieldindex = paragraph.ChildEntities.IndexOf(formulafield) + 1;
//Create a temporary paragraph
WParagraph tempParagraph = new WParagraph(footer.Document);
//Append NUMPAGES field
for (int i = 0; i < tempParagraph.ChildEntities.Count; i++)
//Get the NUMPAGES field from the temporary paragraph and insert it as first operand in the formula field paragraph.
if (tempParagraph.ChildEntities[i] is WField &&
(tempParagraph.ChildEntities[i] as WField).FieldType == FieldType.FieldNumPages)
//The NUMPAGES field is inserted at the index next to Formula field in the paragraph
int itemsCount = paragraph.ChildEntities.Count;
fieldindex += paragraph.ChildEntities.Count - itemsCount;
IWTextRange text = new WTextRange(footer.Document);
//Insert the operater and second operand to the formula field
text.Text = " - " + 1;
//Add the page number paragraph to the required footer in the document
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.