Forums

Overview » C# » Set the Footer Page Number of the Word Document with C#
Reply

Set the Footer Page Number of the Word Document with C#

tom linus
Newbie



Since: 18 Jan 2011
Posts: 21
Posted 21 Feb 2011 08:28:34

These days, I was puzzled with an issue. It’s about how to set the page number in the Word document with C# word footer. So one day, I searched the Internet to get some information about it. I learnt a lot of things. Here I want to share with you about it.
If you are a programmer, you can follow me. In my method, I use a component to help me complete the issue. Then, I want to tell you about my method.
I think that you may know how to insert page number into the footer in MS Word. Here I don’t want to talk about it. I will tell you the way to solve the problem without C# guidance. First, you should create a paragraph in the section, I omit this line in my example, you can add it by yourself. Then you may append a field for the page number. One field is not enough, then you should append another field for unmber of pages. After that you can set the font, size and color of the footer text. In my example, I just set the alignment of the page number.
Following is the code for inserting page number into the footer with C#:
C#:
//Add a field for the page number
footer.AppendField("page number", FieldType.FieldPage);

//Append text
footer.AppendText(" out of ";

//Add another field for number of pages
footer.AppendField("number of pages", FieldType.FieldNumPages);
footer.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Center;

These days, I was puzzled with an issue. It’s about how to set the page number in the Word document with C# word footer. So one day, I searched the Internet to get some information about it. I learnt a lot of things. Here I want to share with you about it.
If you are a programmer, you can follow me. In my method, I use a component to help me complete the issue. Then, I want to tell you about my method.
I think that you may know how to insert page number into the footer in MS Word. Here I don’t want to talk about it. I will tell you the way to solve the problem without C# guidance. First, you should create a paragraph in the section, I omit this line in my example, you can add it by yourself. Then you may append a field for the page number. One field is not enough, then you should append another field for unmber of pages. After that you can set the font, size and color of the footer text. In my example, I just set the alignment of the page number.
Following is the code for inserting page number into the footer with C#:
C#:
//Add a field for the page number
footer.AppendField("page number", FieldType.FieldPage);

//Append text
footer.AppendText(" out of ";

//Add another field for number of pages
footer.AppendField("number of pages", FieldType.FieldNumPages);
footer.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Center;
tom linus
Newbie



Since: 18 Jan 2011
Posts: 21
Replied 24 Feb 2011 05:40:40
It's very useful. Thank you.[]

Reply to this topic

Message
Reply
Follow us on twitter Subscribe to our RSS feed
Activate your free membership today | Login | Currency