I am trying to create a ppt using shape crawler. Now in one of my slides i was trying to add an image which i have had no luck with.
#region Slides Creation
// create a new presentation
var pres = new Presentation();
#region Slide 1
var slide1 = pres.Slides[0];
#endregion Slide 1
#region Slide 2 - 11
for(int i = 1; i <=10; i++)
pres.Slides.Add(slide1);
#endregion Slide 2 - 11
pres.SaveAs("test.pptx");
#endregion Slide Creation
here in the code above i create my slides and then in a particular slide marked by the index in [] i am trying to add an image
#region Slide Decoration
var shape = pres.Slides[0].Shapes;
using var image = new FileStream("D:\Test Projects\ShapeCrawlerTest\assets\coverPhoto.png", FileMode.Open, FileAccess.Read);
// Add picture to the shape
// You need to specify the position (left, top) and size (width, height)
//shape.AddRectangle(0, 0, pres.SlideWidth, pres.SlideHeight);
// Fill the rectangle with the picture
//var addedshape = (IPicture)shape.Last();
var picture = shape.GetByName<IPicture>("Picture 1");
// change image
picture?.Image?.Update("D:\Test Projects\ShapeCrawlerTest\assets\coverPhoto.png");
pres.Save();
//shape.AddRectangle(x: 0, y: 0, width: pres.SlideWidth, height: pres.SlideHeight);
//var addedShape = shape.Last();
//addedShape.TextFrame!.Text = "Hello World!";
var shape2 = pres.Slides[1].Shapes;
shape2.AddTable(0,0,2,2);
var tableadded = shape2.Last();
tableadded.X = (pres.SlideWidth - tableadded.Width) / 2;
tableadded.Y = (pres.SlideHeight - tableadded.Height) / 2;
pres.Save();
#endregion Slide Decoration
Here in the documentation on github for this library there is no proper explanation to do the same so i was experimenting with this but have not received any results yet. I get an error on picture 1 every time which i assume is the default picture name for the first picture in the slide. now if i use the name of my original picture that too gives the same error
please help me out here. i am not sure what to do now.
thanks