We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to add image to slide at given position with given width and height?

Hi, Support:

Would you please tell me How to a image to a give slide at given position with given WxH?
for example:
PPT.Slides(1).addimage(ImageFilePath, new Point(0,0), new size(W,H))

Another request is that how add multiply text into a blank slide withe given fontname,fontsize, fontcolor and position?

How to work it out?
Thanks!

@ducaisoft,
Thank you for the query. You can add the image to the slide as shown below:

Dim presentation = New Presentation()

Dim bitmap = New Bitmap(dataPath + "image.png")
Dim image = presentation.Images.AddImage(bitmap)
presentation.Slides(0).Shapes.AddPictureFrame(ShapeType.Rectangle, 20, 20, bitmap.Width, bitmap.Height, image)

presentation.Save(dataPath + "image-out.pptx", SaveFormat.Pptx)

More examples (C#): Image
API Reference (C#): IImageCollection.AddImage Method, IShapeCollection Methods

You can add the text to the slides as follows:

Dim presentation = New Presentation()

Dim autoShape = presentation.Slides(0).Shapes.AddAutoShape(ShapeType.Rectangle, 20, 20, 600, 300)
autoShape.FillFormat.FillType = FillType.NoFill
autoShape.LineFormat.FillFormat.FillType = FillType.NoFill
autoShape.TextFrame.TextFrameFormat.AnchoringType = TextAnchorType.Top
autoShape.TextFrame.Paragraphs.Clear()

Dim parapraph = New Paragraph()
parapraph.Text = "Hello, Aspose!"
autoShape.TextFrame.Paragraphs.Add(parapraph)

Dim fontData = New FontData("Verdana")
parapraph.ParagraphFormat.DefaultPortionFormat.LatinFont = fontData

parapraph.ParagraphFormat.DefaultPortionFormat.FontHeight = 30
parapraph.ParagraphFormat.DefaultPortionFormat.FillFormat.FillType = FillType.Solid
parapraph.ParagraphFormat.DefaultPortionFormat.FillFormat.SolidFillColor.Color = Color.Blue

presentation.Save(dataPath + "text-out.pptx", SaveFormat.Pptx)

Documents (C#): Manage Text
API Reference (C#): IAutoShape Interface, IParagraph Interface