Insert Header/Footer from another document

I have multiple preformatted Word document with placeholders e.g. $AMOUNT$, $DATE$, ... In every document I have defined the same header and footer.

I want to create an empty word document that contains the static header and footer and those two elements be injected into the other preformatted document so that after changing the document containing header and footer those changes will be merged into the preformatted documents

TemplateDocument 2Resulting DocumentDocument 2Resulting Document 2
Header
Header
Header

BodyBodyBody 1Body 1
Footer
Footer
Footer


TemplateDocument 3Resulting Document 3
Header 1
Header 1

Body 2Body 2
Footer 1
Footer 1


I tried to load the document containing header and footer and tried to set those values to the preformated document. But I do not know how to do it, since all properties are GET only

All the Best,
Michael


3 Replies

MR Manikandan Ravichandran Syncfusion Team November 8, 2021 04:36 PM UTC

Hi Michael,

Thank you for contacting Syncfusion support.

From the given details, we have found that your requirement to copy the header and footer from one Word document and insert them into the header and footer of another existing document using DocIO. We have attached the sample application to achieve your requirement and it can be downloaded from the below link.
https://www.syncfusion.com/downloads/support/forum/170149/ze/ConsoleAppBase_F170149-2101038385

In above sample, we have done the following things,
1. Loaded the documents (Template.docx and Test.docx).
2. Got the header and footer items from the first document (Template.docx) and then insert into the second document (Test.docx) of Header and footer
3. Saved the second document (Test.docx).

Please let us know if you have any other queries.

Regards,
Manikandan Ravichandran 



MM Michael Mairegger November 9, 2021 10:21 AM UTC

Hi Manikandan,

thank you for the support and the provided example. The code works, the only modification that I had to do is the removal of the following line. What do you think about inserting this use case in the documentation, because I think this might be a common use case for working

section.PageSetup.Margins = pageSetup.Margin

Regards,
Michael Mairegger



MR Manikandan Ravichandran Syncfusion Team November 9, 2021 11:51 AM UTC

Hi Michael,

Thank you for your update.

We have considered your request and we have already planned to publish this use case in our documentation.

Please let us know if you have any other queries.

Regards,
Manikandan Ravichandran 


Loader.
Up arrow icon