ImportContent
Hi,
I try to import a Word document into a main document. the main document contains headers and footers, but the imported document shall not have these headers and footers. How can I do that?
SIGN IN To post a reply.
7 Replies
DB
Dilli Babu Nandha Gopal
Syncfusion Team
November 14, 2018 10:05 AM UTC
Hi Bodo,
Thank you for contacting Syncfusion support.
Yes, it is possible to import a Word document with headers and footers to a Word document using ImportContent method. Please find the code example for the same.
|
//Open the source document
WordDocument sourceDocument = new WordDocument(sourceFileName);
//Open the destination document
WordDocument destinationDocument = new WordDocument(targetFileName);
//Import the contents of source document at the end of destination document
destinationDocument.ImportContent(sourceDocument, ImportOptions. KeepSourceFormatting);
//Close the document instance
sourceDocument.Close();
//Save the destination document
destinationDocument.Save(outputFileName, FormatType.Docx);
//Close the document instance
destinationDocument.Close(); |
We have explained about different ImportOptions and their behaviors in the following API documentation link.
Please let us know if you have any questions.
Regards,
Dilli babu.
BJ
Bodo Jäger
November 14, 2018 12:20 PM UTC
Hi Dilli,
thanks for your answer, but you misunderstand me.
I have a doc with header and footer, and want to import another doc without header and footer.
And the imported part shall not have header and footer.
Bodo
DB
Dilli Babu Nandha Gopal
Syncfusion Team
November 15, 2018 10:12 AM UTC
Hi Bodo,
Thank you for your update.
We have prepared a sample application to merge sub Word document at the end of main Word document which doesn’t preserves sub Word document’s headers and footers in the main Word document. The sample can be downloaded from the following link.
To know more about importing sub Word document at the end of main Word document and to preserve header and footers from the main Word document, kindly refer our following discussion forum.
Please let us know if you have any questions.
Regards,
Dilli babu.
BJ
Bodo Jäger
November 15, 2018 10:39 AM UTC
Hi,
Attachment: NewSample_a8c47f1d.zip
you still misunderstand me.
I've attached the expected result.
The imported file shall not have the headers of the main doc.
Bodo
Attachment: NewSample_a8c47f1d.zip
DB
Dilli Babu Nandha Gopal
Syncfusion Team
November 15, 2018 01:06 PM UTC
Hi Bodo,
We regret for the inconvenience.
We have modified the sample based on your requirement which can be downloaded from following link.
Note: We suspect that the imported document doesn’t have header and footer, which will be preserved as it in Main Word document after merging.
Please find the output documents comparison in below.
|
|
Regards,
Dilli babu.
BJ
Bodo Jäger
November 15, 2018 03:26 PM UTC
Hi Dilli,
thanks a lot.
Your last solution works fine for me.
Bodo
DB
Dilli Babu Nandha Gopal
Syncfusion Team
November 16, 2018 05:39 AM UTC
Hi Bodo,
We are glad to know that the provided solution fulfills your requirement. Please let us know if you need any further assistance.
Regards,
Dilli babu.
SIGN IN To post a reply.
- 7 Replies
- 2 Participants
-
BJ Bodo Jäger
- Nov 13, 2018 12:15 PM UTC
- Nov 16, 2018 05:39 AM UTC