Add document to Diagram via OLE
What is OLE object for Diagram?
The OLE technology provided by Microsoft allows to insert some other document content into the shape with size and coordinates which are previosly selected by X, Y, Width and Height of the currently editing Diagram page. For example, the Slides document can be inserted in the Diagram document inside of shape as was presented in the example below.
Add document to Diagram via OLE
GroupDocs.Merger provides an ability to add other single document as embedded document to Presentation.
Here are the steps for it:
- Initialise OleDiagramOptions class with embedded file path and page number;
- Instantiate Merger object with source document path or stream;
- Call ImportDocument method and pass OleDiagramOptions object to it;
- Call Save method and pass desired file path to save resultant document.
The following code sample demonstrates how to add other single document as embedded document to Diagram page:
string filePath = @"c:\sample.vsdx";
string filePathEmbedded = @"c:\embedded.pptx";
string filePathOut = @"c:\output\result.vsdx";
int pageNumber = 2;
OleDiagramOptions oleDiagramOptions = new OleDiagramOptions(filePathEmbedded, pageNumber);
oleDiagramOptions.X = 1;
oleDiagramOptions.Y = 1;
oleDiagramOptions.Width = 2;
oleDiagramOptions.Height = 1;
using (Merger merger = new Merger(filePath))
{
merger.ImportDocument(oleDiagramOptions);
merger.Save(filePathOut);
}
More resources
Advanced Usage Topics
To learn more about document merging features, please refer the advanced usage section.
GitHub Examples
You may easily run the code above and see the feature in action in our GitHub examples:
- GroupDocs.Merger for .NET examples, plugins and showcase
- GroupDocs.Merger for Java examples, plugins and showcase
Free Online App
Along with full featured .NET library we provide simple, but powerful free Apps.
You are welcome to merge your documents with our free online GroupDocs Merger App.