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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How do I Append One Document to Another document?

 

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

 

 

 

Article ID: Published Date: Last Revised Date: Platform: Control:
285 04/30/2011 07/10/2014 Windows Forms DocIO
Tags:
Did you find this information helpful?
Comments
Jeff Smith Jan 26, 2017
this code does NOT append the documents.
Reply
Add Comment
You must log in to leave a comment

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