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

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 forumsDirect-Trac, 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