We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

ImportContent

Thread ID:

Created:

Updated:

Platform:

Replies:

140899 Nov 13,2018 12:15 PM UTC Nov 16,2018 05:39 AM UTC WinForms 7
loading
Tags: DocIO
Bodo Jäger
Asked On November 13, 2018 12:15 PM UTC

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?

Dilli Babu Nandha Gopal [Syncfusion]
Replied On 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. 


Bodo Jäger
Replied On 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

Dilli Babu Nandha Gopal [Syncfusion]
Replied On 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. 


Bodo Jäger
Replied On November 15, 2018 10:39 AM UTC

Hi,
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

Dilli Babu Nandha Gopal [Syncfusion]
Replied On 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. 


Bodo Jäger
Replied On November 15, 2018 03:26 PM UTC

Hi Dilli,
thanks a lot.
Your last solution works fine for me.

Bodo

Dilli Babu Nandha Gopal [Syncfusion]
Replied On 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. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;