@puri
Thanks for your patience. We have investigated the issue and would like to update you that we must add headers/footers to unlink sections, but adding headers/footers also adds extra space, which leads to adding of new pages, which is undesirable. So, a workaround to resolve this issue is to add zero-height headers/footers, this will unlink sections and preserve the initial height of the documents.
private static void UnLinkToPreviousSafe(Section section)
{
if (section.HeadersFooters.Count == 0)
{
SectPr sectPr = section.SectPr;
sectPr.FooterDistance = 0;
sectPr.HeaderDistance = 0;
}
section.HeadersFooters.LinkToPrevious(false);
}
To get desired output, please, modify your code as followig, it will help you to get desired results.
you should use this function
UnLinkToPreviousSafe(document.FirstSection);
Instead of
document.FirstSection.HeadersFooters.LinkToPrevious(false);
Please feel free to contact us for any further assistance.
Best Regards,