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.

Tue Aug 31, 2021 6:31 pm

Hello, when I want to add image to table cell I get "Image not belong with persentation." error in line
Code: Select all
table[c, r].FillFormat.PictureFill.Picture.EmbedImage = imgData;

my version is 4.11.0

Code: Select all
IImageData imgData =null;
                    var attachedFile = files.FirstOrDefault(x => x.FileName == fileName);
                    if (attachedFile != null)
                    {
                        byte[] bytes = null;
                        using (var stream = new MemoryStream())
                        {
                            attachedFile.CopyTo(stream);
                            bytes = stream.ToArray();
                        }
                        if (bytes != null && bytes.Length > 0)
                        {
                            using (MemoryStream ms = new MemoryStream(bytes))
                            {
                                imgData = presentation.Images.Append(ms);
                            }
                        }
                    }
                    if (imgData != null)
                    {                       
                        table[c, r].FillFormat.FillType = FillFormatType.Picture;
                        table[c, r].FillFormat.PictureFill.Picture.EmbedImage = imgData;
                        table[c, r].FillFormat.PictureFill.FillType = PictureFillType.Tile;
                    }

omurertanis
 
Posts: 22
Joined: Tue Mar 30, 2021 7:56 pm

Wed Sep 01, 2021 1:55 am

Hello,

Thanks for your inquiry.
I simulated a pptx file, an image file and then tested your case, but I did not reproduce your issue. To help us reproduce your issue and solve it, please provide your input file. You can upload them here or send them to us (support@e-iceblue.com) via email. Thanks in advance.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Wed Sep 01, 2021 1:04 pm

Hello,
I have added files.

omurertanis
 
Posts: 22
Joined: Tue Mar 30, 2021 7:56 pm

Thu Sep 02, 2021 2:20 am

Hello,

Thanks for providing your input file.
I tested the following code with the Spire.Presentation V4.11.0, but I still did not reproduce your issue. please tell us your project target framework (e.g. .NET Framework 4.5) and your OS information (e.g. Windows7, 64bit) for further investigation. Thanks in advance.

Code: Select all
            Presentation presentation = new Presentation();
            presentation.LoadFromFile("temp.pptx");

            IImageData imgData = null;
            byte[] bytes = null;

            using (var stream = new MemoryStream())
            {
                FileStream fileStream = File.OpenRead("golden_cup_PNG94637.png");
                fileStream.CopyTo(stream);
                bytes = stream.ToArray();
            }
            if (bytes != null && bytes.Length > 0)
            {
                using (MemoryStream ms = new MemoryStream(bytes))
                {
                    imgData = presentation.Images.Append(ms);
                }
            }
            ITable table = presentation.Slides[2].Shapes[1] as ITable;

            for(int r=0; r<table.TableRows.Count; r++)
            {
                for(int c=0; c < table.ColumnsList.Count; c++)
                {
                    if (imgData != null)
                    {
                        table[c, r].FillFormat.FillType = FillFormatType.Picture;
                        table[c, r].FillFormat.PictureFill.Picture.EmbedImage = imgData;
                        table[c, r].FillFormat.PictureFill.FillType = PictureFillType.Tile;
                    }
                }
            }

            presentation.SaveToFile("result.pptx", FileFormat.Pptx2013);



Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Wed Sep 08, 2021 10:18 am

Hello,

Greetings from E-iceblue!
How is your issue now? Could you please give us some feedback at your convenience?

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Return to Spire.Presentation