Spire.Presentation is a professional PowerPoint® compatible library that enables developers to create, read, write, modify, convert and Print PowerPoint documents. Get free and professional technical support for Spire.Presentation for .NET, Java, Android, C++, Python.

Fri Mar 10, 2017 10:36 am

HI

My requirement is to be able to include attachments of any file-type (mostly Office documents, but could be also PDFs and pictures) on a slide.

I've seen the OleObject implementation. But it seems to work only for Excel? Also, i need to provide a custom thumbnail, otherwise it will have a thumbnail "OLE Object".

I can drag'n'drop any filetype in the PowerPoint-Client. It will automatically create an Icon and show the name of the file.

How can i achieve something similar using your API? Icon is not a big problem, i can use a generic one. But show name of file?

mhofer1976
 
Posts: 5
Joined: Thu Mar 09, 2017 12:24 pm

Mon Mar 13, 2017 10:03 am

Hello,

Thanks for your inquiry and sorry for the late reply as weekend.
After an initial investigation, we found the OleObject implementation works only for word and excel at present. Some issue occurs in pdf and picture embedding and I have referred them to our Dev team for a further analysis and update. Once there's good news on it, I will inform you immediately.
Attache the code for embedding word and excel:
Code: Select all
 
//use custom thumbnail
            Image image = Image.FromFile(@"C:\Users\Administrator\Pictures\exp\pic.jpg");
            Presentation ppt = new Presentation();
            IImageData oleImage = ppt.Images.Append(image);
//1.add word document
Document doc = new Document();
            doc.LoadFromFile(@"F:\test\doc\test.docx");
 using (MemoryStream ms = new MemoryStream())
            {
                doc.SaveToStream(ms, Spire.Doc.FileFormat.Docx);
                ms.Position = 0;
                Spire.Presentation.IOleObject oleObject = ppt.Slides[0].Shapes.AppendOleObject("word", ms.ToArray(), new Rectangle(60, 60, 20, 20));
                //oleObject.SubstituteImagePictureFillFormat.Picture.EmbedImage = oleImage;
                oleObject.IsIconVisible = true;
                oleObject.ProgId = "Word.Document.12";
            }
            //2.add embed excel
            Workbook book = new Workbook();
            book.LoadFromFile(@"F:\test\xls\limit.xlsx");
 using (MemoryStream ms = new MemoryStream())
            {
                book.SaveToStream(ms, Spire.Xls.FileFormat.Version2010);
                ms.Position = 0;
                Spire.Presentation.IOleObject oleObject = ppt.Slides[0].Shapes.AppendOleObject("excel", ms.ToArray(), new Rectangle(100, 100, 20, 20));
                //for convenience,just use the same image as example
                oleObject.SubstituteImagePictureFillFormat.Picture.EmbedImage = oleImage;
                oleObject.ProgId = "Excel.Sheet.12";
            }

As for the name issue, sorry that I can't see the name even in ms office, could you show me a screenshoot?

Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Return to Spire.Presentation