I need to insert an image from a database into Aspose slides. I found a Java example below but I need a VB version of the same.
'Java Version
I need to insert an image from a database into Aspose slides. I found a Java example below but I need a VB version of the same.
'Java Version
Hi,
Presentation pres = new Presentation();//Get the first slideISlide sld = pres.Slides[0];//Instantiate the Image classIPPImage imgx =null;//In database, image is stored as byte array so instead of file stream, it needs to be written as ByteArrayInputStreamimgx = pres.Images.AddImage( new MemoryStream(PASS_IMAGE_BYTEARRAY));//Add Picture Frame with height and width equivalent of Picturesld.Shapes.AddPictureFrame(ShapeType.Rectangle, 50, 150, imgx.Width, imgx.Height, imgx);//Write the PPTX file to diskpres.Save(“ImgDB.pptx”, SaveFormat.Pptx);
Thank you so much for your help! It worked. Now, I have another problem. I am having trouble deleting predefined text - Click to edit Master Title Styles and Click to edit Title Styles that appear by default on the slides. I am coding in VB .Net. Any help in this regard will be much appreciated.
I get the following error when the value of 'i' is more than 10.
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
Below is the code snippet:
Using pres As Presentation = New Presentation()
'Instantiate slide
Dim sld As ISlide = pres.Slides.AddEmptySlide(pres.LayoutSlides.GetByType(SlideLayoutType.TitleAndObject))
'Instantiate SlideCollection class
Dim slds As ISlideCollection = pres.Slides
For i = 0 To dt.Rows.Count - 1
slds.AddEmptySlide(pres.LayoutSlides(i))
'Get the slide
sld = DirectCast(pres.Slides(i), ISlide)
'Add an AutoShape of Rectangle type
Dim ashp As IAutoShape = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 75, 475, 575, 50)
ashp.TextFrame.Paragraphs(0).Portions(0).Text = ""
'Accessing the text frame
Dim txtFrame As ITextFrame = ashp.TextFrame
'Create the Paragraph object for text frame
Dim para As IParagraph = txtFrame.Paragraphs(0)
'Create Portion object for paragraph
Dim portion As IPortion = para.Portions(0)
'Set Text
portion.Text = dt.Rows(i).Item(0)
Next
'Save ppt file
End Using
Hi,