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.

Sun Sep 25, 2022 4:02 am

Sorry if this double posts.

Is there a way to embed images into a presentation using this? so far I haven't had any luck, and when we open the presentations up we get some funk results.


Screenshot 2022-09-24 205713.png

top left photo was added with Powerpoint, rest were added using spire.

maveric191
 
Posts: 4
Joined: Sun Sep 25, 2022 3:50 am

Mon Sep 26, 2022 8:07 am

Hello,

Thanks for your inquiry.
For how to embed images into a presentation, you can refer to our help document, I put the links of help document below.
If these help document don’t help you, to help us do further investigation and work out a solution for you, please offer the following message, thanks for your assistance in advance.

1) Your test code.
2) Your input presentation document and input images.
3) The presentation document you expect after embedding images into it.

For Net: https://www.e-iceblue.com/Tutorials/Spi ... ument.html
For Java: https://www.e-iceblue.com/Tutorials/Jav ... -Java.html

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 860
Joined: Tue Mar 08, 2022 2:02 am

Tue Sep 27, 2022 7:20 am

Hi Abel,

Thank you for the quick answer. Below is the code that I'm using to insert the pictures, as well as text(seems to be just fine), into placeholders from our master slides. Hopefully I'm missing something easy/stupid.

this code doesn't exactly match the picture I posted however its only missing the last two placeholders. 0 starts with the large picture top left.


Code: Select all
IAutoShape shape = presentation.Slides[0].Shapes[0] as IAutoShape;
                            if (shape is not null)
                            {
                                shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Picture;
                                shape.Fill.PictureFill.Picture.Url = imageFile;
                                shape.Fill.PictureFill.FillType = Spire.Presentation.Drawing.PictureFillType.Stretch;
                                shape.Line.FillFormat.SolidFillColor.Color = Color.Transparent;
                            }

                            //item description
                            IAutoShape shape1 = presentation.Slides[0].Shapes[1] as IAutoShape;
                            if (shape1 is not null)
                            {
                                shape1.AppendTextFrame(ItemDesc);
                            }

                            //female conn
                            IAutoShape shape2 = presentation.Slides[0].Shapes[2] as IAutoShape;
                            if (shape2 is not null)
                            {
                                shape2.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Picture;
                                shape2.Fill.PictureFill.Picture.Url = FConn;
                                shape2.Fill.PictureFill.FillType = Spire.Presentation.Drawing.PictureFillType.Stretch;
                                shape2.Line.FillFormat.SolidFillColor.Color = Color.Transparent;
                            }
                            //ecode
                            IAutoShape shape3 = presentation.Slides[0].Shapes[3] as IAutoShape;
                            if (shape3 is not null)
                            {
                                shape3.AppendTextFrame(filename);
                            }

                            //male conn
                            IAutoShape shape4 = presentation.Slides[0].Shapes[4] as IAutoShape;
                            if (shape4 is not null)
                            {
                                shape4.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Picture;
                                shape4.Fill.PictureFill.Picture.Url = MConn;
                                shape4.Fill.PictureFill.FillType = Spire.Presentation.Drawing.PictureFillType.Stretch;
                                shape4.Line.FillFormat.SolidFillColor.Color = Color.Transparent;
                            }

                            //color code 1
                            IAutoShape shape5 = presentation.Slides[0].Shapes[5] as IAutoShape;
                            if (shape5 is not null)
                            {
                                shape5.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Picture;
                                shape5.Fill.PictureFill.Picture.Url = L1;
                                shape5.Fill.PictureFill.FillType = Spire.Presentation.Drawing.PictureFillType.Stretch;
                                shape5.Line.FillFormat.SolidFillColor.Color = Color.Transparent;
                            }

                            //save to file
                            presentation.SaveToFile(FilePath, FileFormat.Pptx2013);

maveric191
 
Posts: 4
Joined: Sun Sep 25, 2022 3:50 am

Tue Sep 27, 2022 10:56 am

Hello,

Thanks for your feedback.
Don’t the last two placeholders fill the corresponding pictures in result document? If so, I simulated a master slide to test this scenario, and I didn’t reproduce it, to help do further investigation, please offer the following message. Thanks for your assistance in advance.
In addition, you should use the following code to get master slide object.
IMasterSlide masterSlide = ppt.Masters[0];

1) Your input presentation document.
2) The images for inserting to master slide.
3) The presentation document you expect after embedding images into it.
4) Application type, such as Console App, .NET Framework 4.8.
5) Your test environment, such as OS info (E.g. Windows 7, 64-bit) and region setting (E.g. China, Chinese).

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 860
Joined: Tue Mar 08, 2022 2:02 am

Wed Sep 28, 2022 4:29 pm

first 3 are all attached in the zip file
4) Application type, such as Console App, .NET Framework 4.8. - .net Winform
5) Your test environment, such as OS info (E.g. Windows 7, 64-bit) and region setting (E.g. China, Chinese). - windows 7, 10, and 11

maveric191
 
Posts: 4
Joined: Sun Sep 25, 2022 3:50 am

Thu Sep 29, 2022 10:20 am

Hello,

Thanks for your feedback.
Do you want to achieve the effect of screenshot1 instead of screenshot2? If so, you need to change the code of inserting image. I put a code snippet below for your reference.
If you have any issue, just feel free to contact us.

Code: Select all
IAutoShape shape = presentation.Slides[1].Shapes[1] as IAutoShape;
            if (shape != null)
            {
                shape.InsertPicture(@"../../data/.3132A.jpg");
            }



Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 860
Joined: Tue Mar 08, 2022 2:02 am

Fri Sep 30, 2022 8:58 am

sorry for the late reply.
Yes it should look like Screenshot 1. Will try the change in the code shortly and report back.

maveric191
 
Posts: 4
Joined: Sun Sep 25, 2022 3:50 am

Fri Sep 30, 2022 9:32 am

Hello,

Thanks for your feedback.
Looking forward to your reply. Have a nice day :D !

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 860
Joined: Tue Mar 08, 2022 2:02 am

Return to Spire.Presentation