I have a word doc with header and footer. I need to insert a page to the end of the doc, with the header and footer. Any hints?
Hi Linda,
Try adding a new Section
element, for example, like this:
DocumentModel document = ...
var section = new Section(document);
document.Sections.Add(section);
section.HeadersFooters.Add(
new HeaderFooter(document, HeaderFooterType.HeaderDefault,
new Paragraph(document, "Sample header.")));
section.HeadersFooters.Add(
new HeaderFooter(document, HeaderFooterType.FooterDefault,
new Paragraph(document, "Sample footer.")));
By default, the new Section
will be added with a Section Break (Next Page) and thus it will result in inserting a new page at the end.
I hope this helps.
Regards,
Mario
Thanks, but how do I get the header/footer from the existing doc instead of the sample header/footer string?
Hi Linda,
I initially thought that you want to add a new page with a different header and footer.
Anyway, try using this instead:
DocumentModel document = ...
document.Content.End.InsertRange(
new Paragraph(document, new SpecialCharacter(document, SpecialCharacterType.PageBreak))
.Content);
If the problem remains, please send us the input document that you have and the output document that you would like to get.
You can create the output document by manually editing (with Microsoft Word) your input document.
I’ll investigate the documents and provide a snippet code that achieves the desired output.
Regards,
Mario
YES, this worked! Thanks much!