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

How do I Append One Document to Another document?

Platform: WinForms |
Control: DocIO |
Published Date: April 30, 2011 |
Last Revised Date: July 10, 2014

 

DocIO provide the support for importing one document into another document using two ways. One is by directly importing the content using ImportContent() method. Another one is by appending ole object to import the content. The following code snippet illustrates how to import one document into another document.

 

 

C#

//Directly importing the content of one document into another document

 

//Open the source document

WordDocumentsourceDocument = new WordDocument("Essential DocIO.doc");

//Open the destination document

WordDocumentdestDocument = new WordDocument("Essential PDF.doc");

//Imports the content of source document into destination document

destDocument.ImportContent(sourceDocument, true);

//Save the destination document

 destDocument.Save("Sample.doc");

 

 

//Importing the content as OLE object into the another document

 

//opens the document

WordDocumentdocument = new WordDocument("Essential PDF.doc");

document.LastSection.AddParagraph();

document.LastSection.AddParagraph();

document.LastParagraph.AppendText("Essential DocIO.doc has been inserted as OLE Object");

document.LastSection.AddParagraph();

//Loads the picture (for OLE Object)

WPicturepic = new WPicture(document);

pic.LoadImage(System.Drawing.Image.FromFile("DocIO.jpg"));

//Appending the document as OLE Object into another document

WOleObjectoleObject = document.LastParagraph.AppendOleObject("Essential DocIO.doc", pic, OleObjectType.Word_97_2003_Document);

oleObject.DisplayAsIcon = true;

//Save the document

document.Save("Sample.doc");

 

VB

 

'Directly importing the content of one document into another document

 

'Open the source document

DimsourceDocument As New WordDocument("Essential DocIO.doc")

'Open the destination document

DimdestDocument As New WordDocument("Essential PDF.doc")

'Imports the content of source document into destination document

destDocument.ImportContent(sourceDocument, True)

'Save the destination document

destDocument.Save("Sample.doc")

 

'Importing the content as OLE object into the another document

 

'opens the document

Dimdocument As New WordDocument("Essential PDF.doc")

document.LastSection.AddParagraph()

document.LastSection.AddParagraph()

document.LastParagraph.AppendText("Essential DocIO.doc has been inserted as OLE Object")

document.LastSection.AddParagraph()

'Loads the picture (for OLE Object)

Dimpic As New WPicture(document)

pic.LoadImage(System.Drawing.Image.FromFile("DocIO.jpg"))

'Appending the document as OLE Object into another document

DimoleObject As WOleObject = document.LastParagraph.AppendOleObject("Essential DocIO.doc", pic, OleObjectType.Word_97_2003_Document)

oleObject.DisplayAsIcon = True

'Save the document

document.Save("Sample.doc")

 

 

The following sample illustrates the above code

http://help.syncfusion.com/samples/DocIO.Web/DocIOWebSamples/ImportDocument/main.htm

 

 

 

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment
Comments
Jeff Smith
Jan 26, 2017
this code does NOT append the documents. Reply

Please sign in to access our KB

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

Up arrow 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.