coffeycathal_cp
68351622e7
Added basic support for PageNumber and PageCount place holders.
When inserted into a Header or Footer Word will automatically display the correct value foreach page.
Word will not automatically update these place holders if inserted inside a document level Paragraph.
You need to right click and select update field. I therefore suggest that you only use these place holders inside Headers and Footers.
Added
-------
Paragraph.AppendPageNumber(PageNumberFormat)
Paragraph.InsertPageNumber(PageNumberFormat, int index)
Paragraph.AppendPageCount(PageNumberFormat)
Paragraph.InsertPageCount(PageNumberFormat, int index)
Example
-----------
// Create a new document.
using (DocX document = DocX.Create(@"Test.docx"))
{
// Add Headers to the document.
document.AddHeaders();
// Get the default Header.
Header header = document.Headers.odd;
// Insert a Paragraph into the Header.
Paragraph p0 = header.InsertParagraph();
// Append place holders for PageNumber and PageCount into the Header.
// Word will replace these with the correct value foreach Page.
p0.Append("Page (");
p0.AppendPageNumber(PageNumberFormat.normal);
p0.Append(" of ");
p0.AppendPageCount(PageNumberFormat.normal);
p0.Append(")");
// Save the document.
document.Save();
}