Delivering Objects to PPT


#1

I am using a charting tool (NetCharts) to provide charts to a website written in .NET. I am wondering if Aspose.Slides has the capability to deliver an object that produces a graphic (these charts) to powerpoint? My customer would like to see a button in .NET that can be clicked to open up these charts in a powerpoint presentation.


#2

Does anyone who works for Aspose know if you can deliver objects to powerpoint using your tool?


#3

Sorry for delay. Sure, Aspose.Slides can insert any images to a presentation.
The most simple example for that is Pictures demo. It’s included in the msi installer
and available in both C# and VB.Net.


#4

Thanks Alexey. I have tried adding an image using this code from your demo but have been unable to get it to work. You demo in a vb class. Is there a line or two of code you could provide that would just add an image to a ppt?

I have tried something like this in my .NET code (VB):

Dim fileName As String = MapPath(".") + "\\AsposeTest.ppt"

Dim pres As Presentation = New Presentation(fileName)

Dim slides As Slides = pres.Slides

Dim pholders As Placeholders = slides(0).Placeholders

Dim th As TextHolder = pholders.Item(0)

If th.Text = "Aspose Test" Then

th.Paragraphs(0).Portions(0).Text = "Hello World"

' Add new picture

Dim picid As Integer = pres.Pictures.Add(New Picture(pres, MapPath(".") + "\\47.jpg"))

' Assign new picture to the first slide background

pres.Slides(0).Background.FillFormat.PictureId = picid

'save

Me.Response.ContentType = "application/vnd.ms-powerpoint"

Me.Response.AppendHeader("Content-Disposition", "attachment; filename=demoppt.ppt")

Me.Response.Flush()

Dim st As System.IO.Stream = Me.Response.OutputStream

pres.Write(st)

Me.Response.End()

The "Hello World" appears in the placeholder but the image (47.jpg) is not added to the page. Can you tell what I might be missing?

Todd


#5

To change slide’s background at first you should turn off inheritance from master slide.

Dim slide As Slide = pres.GetSlideByPosition(1)
slide.FollowMasterBackground = False

slide.Background.FillFormat.Type = FillType.Picture
slide.Background.FillFormat.PictureId = picid


Also you can add PictureFrame to a slide.

slide.Shapes.AddPictureFrame(picid, x, y, width, height)