Articles in this section
Category / Section

How do I Append One Document to another document in WinForms DocIO?

1 min read

 Our WinForms DocIO feature tour page provides support for importing one document into another document using two methods. One is by directly importing the content using the ImportContent() method. Another is by appending an 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

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

// Import the content of the source document into the 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();

// Load the picture (for OLE Object)

WPicture pic = new WPicture(document);

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

// Append the document as OLE Object into another document

WOleObject oleObject = 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

Dim sourceDocument As New WordDocument("Essential DocIO.doc")

' Open the destination document

Dim destDocument As New WordDocument("Essential PDF.doc")

' Import the content of the source document into the 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()

' Load the picture (for OLE Object)

Dim pic As New WPicture(document)

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

' Append the document as OLE Object into another document

Dim oleObject 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:

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


Conclusion

I hope you enjoyed learning about how do I Append One Document to Another document.

You can refer to our WinForms DocIO feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms DocIO documentation to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments
Please  to leave a comment
Access denied
Access denied