We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Not same headers

Hi !

I try to merge a document several times into one. In the final document, I have only header in the first page, but I want the same header for all pages. I try this :


docSortie.FirstSection.PageSetup.DifferentFirstPageHeaderFooter = false;
docSortie.FirstSection.HeadersFooters.LinkToPrevious(true);


but the result is always unchanged. I must to use Aspose.word 3.5.3.0

Thanks and sorry for my language ^^

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. Please try using the following code:

//Open document

Document doc = new Document(@"Test114\in.doc");

//Copy content from First page Header to primary header if it is not exists

if (doc.FirstSection.HeadersFooters[HeaderFooterType.HeaderPrimary] == null &&

doc.FirstSection.HeadersFooters[HeaderFooterType.HeaderFirst] != null)

{

HeaderFooter hf = new HeaderFooter(doc, HeaderFooterType.HeaderPrimary);

foreach (Node child in doc.FirstSection.HeadersFooters[HeaderFooterType.HeaderFirst].ChildNodes)

{

hf.AppendChild(child);

}

doc.FirstSection.HeadersFooters.Add(hf);

}

//Loop throuhg all sections

foreach (Section section in doc.Sections)

{

section.PageSetup.DifferentFirstPageHeaderFooter = false;

if (!doc.FirstSection.Equals(section))

section.HeadersFooters.LinkToPrevious(true);

}

//Save output document

doc.Save(@"Test114\out.doc");

Hope this helps.

Best regards.