Using DocIO to copy sections between word docs.

Hi, is it possible to copy the header and footer sections from one Word document and insert them into the first page of another existing document?

So effectively using the first Word document as a reusable template for other documents that want the same header and footer look.

Any help would be much appreciated, Thanks


3 Replies 1 reply marked as answer

LB Lokesh Baskar Syncfusion Team October 25, 2021 11:15 AM UTC

Hi Matthew,

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 first page 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. 

In above sample, we have done the following things,
 
1. Loads the documents (Template_1 and Template_2). 
2. Gets the header and footer items from the first document (Template_1) and then insert into the second document(Template_2) of first page header and first page footer. 
3. Sets DifferentFirstPage property to true for inserting header and footer text. 
4. Saves the second document(Template_2).

Please find the output Word document which generated at our end from the below link:
https://www.syncfusion.com/downloads/support/forum/169857/doc/Sample1589674661.docx

Please refer the below UG documentation to know working with headers and footers using DocIO..
https://help.syncfusion.com/file-formats/docio/working-with-sections#working-with-headers-and-footers

Please let us know if you have any other 
queries.

Regards,
Lokesh B
 


Marked as answer

MA Matthew replied to Lokesh Baskar October 26, 2021 02:39 PM UTC

Hello Lokesh Baskar,


Thank you for the excellent code sample and helpful response. This was what I was looking for.


Kind Regards.



LB Lokesh Baskar Syncfusion Team October 27, 2021 05:37 AM UTC

Hi Matthew,

Thank you for your update.

We are glad to know that your problem has been fixed.


Please let us know if you have any other questions and we will be happy to assist you as always.


Regards,
Lokesh B


Loader.
Up arrow icon