IWParagraph header = section.HeadersFooters.Header.AddParagraph();
IWTextRange textRange = header.AppendText("Site: ");
//Set font name and font size for the text ranage
textRange.CharacterFormat.FontName = "Calibri";
textRange.CharacterFormat.FontSize = 12;
IWField field = header.AppendField("CurrentPageNumber", FieldType.FieldPage);
field.CharacterFormat.FontName = "Calibri";
field.CharacterFormat.FontSize = 12;
textRange = header.AppendText("/");
textRange.CharacterFormat.FontName = "Calibri";
textRange.CharacterFormat.FontSize = 12;
field = header.AppendField("TotalNumberOfPages", FieldType.FieldNumPages);
field.CharacterFormat.FontName = "Calibri";
field.CharacterFormat.FontSize = 12; |
IWField field = paragraph2.AppendField("Page", FieldType.FieldPage);
IEntity entity = field;
//Iterates to sibling items until Field End
while (entity.NextSibling != null)
{
if (entity is WTextRange)
//Sets character format for text ranges.
(entity as WTextRange).CharacterFormat.FontSize = 6;
else if ((entity is WFieldMark) && (entity as WFieldMark).Type == FieldMarkType.FieldEnd)
break;
entity = entity.NextSibling;
} |