Example #1
0
        public static void Run()
        {
            string filePath         = Constants.SAMPLE_VSDX;
            string imageFilePath    = Constants.SAMPLE_EMF;
            string embeddedFilePath = Constants.SAMPLE_PPTX;
            string filePathOut      = Path.Combine(Constants.GetOutputDirectoryPath(), Constants.SAMPLE_NAME + Path.GetExtension(filePath));

            FileStream imageStream = new FileStream(imageFilePath, FileMode.Open);

            byte[] imageBytes = ExampleHelper.ToBytes(imageStream);
            imageStream.Close();

            OleDiagramOptions oleDiagramOptions = new OleDiagramOptions(embeddedFilePath, imageBytes, 2);

            oleDiagramOptions.X      = 1;
            oleDiagramOptions.Y      = 1;
            oleDiagramOptions.Width  = 2;
            oleDiagramOptions.Height = 1;

            using (Merger merger = new Merger(filePath))
            {
                merger.ImportDocument(oleDiagramOptions);
                merger.Save(filePathOut);
            }

            Console.WriteLine("Embedded object was added to the source document successfully.");
            Console.WriteLine($"Check output {filePathOut}.");
        }