Quantcast
Channel: Open XML Format SDK forum
Viewing all articles
Browse latest Browse all 1288

How to change the header and footer in the Section Breaks Next Page using OpenXML?

$
0
0

I have a word document file in which I added a Section Break of Next Page, now I want to change the header and footer of that page.

Scenario of example, I have a doc file which has four pages with headers and footers and added fifth page in the section break next page, I want to change the header and footer of the fifth page only. This is achievable manually by deselecting the Link to Previous button in the Word Application but I don't know how to change it using XML?

My code that adds the new page in the section breaks is:

class Program
	{
		static void Main(string[] args)
		{

			string path = @"C:\Riyaz\sample.docx";
			string strtxt = "Hello This is done by programmatically";

		   OpenAndAddTextToWordDocument(path,strtxt);
		}
		public static void OpenAndAddTextToWordDocument(string filepath, string txt)
		{

			using (DocX document = DocX.Load(@"C:\Riyaz\sample.docx"))
			{
				document.InsertSectionPageBreak();
				Paragraph p1 = document.InsertParagraph();
				p1.Append("This is new section");
				document.Save();
			}
		}
	}

Please help.


Viewing all articles
Browse latest Browse all 1288

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>