Reputation: 990
I'm using http://powertools.codeplex.com and/or http://docx.codeplex.com to join word documents. The first document contains a footer, the second document does not. The joined document shows the footer on both pages/sections.
How can I remove the footer of the second section? The footer of the second section is connected to the preceding section. How can this connection be removed by using OpenXML 2.0? In Word this is no problem.
My source code can be found here: http://dl.dropbox.com/u/21096596/OpenXML.zip
Upvotes: 1
Views: 475
Reputation: 990
I found a solution how the footer of the follow-up sections could be replaced:
MainDocumentPart myPart = document.MainDocumentPart;
FooterPart newFtPart = myPart.AddNewPart<FooterPart>();
string ft_ID = myPart.GetIdOfPart(newFtPart);
new DocumentFormat.OpenXml.Wordprocessing.Footer().Save(newFtPart);
foreach (SectionProperties sectProperties in myPart.Document.Descendants<SectionProperties>().Skip(1))
{
FooterReference newFtReference =
new FooterReference() { Id = ft_ID, Type = HeaderFooterValues.Default };
sectProperties.Append(newFtReference);
}
Upvotes: 1