How to Add image from URL to Slide in V14.10?

Dear Aspose Staff,

I found the following codes in the thread “How to add image from URL to slide” in your forum, which explained how to add image from URL to slide. This thread was in 2009.

I’ve tried to use the same code with v14.10 . However, it reports that “Serialize” is not a function/member of Shape object. Is “Serialize” not in Shape object anymore in v14.10?

If so, how can I add image from URL to Slide in v14.10?

I am looking forward to your advice. Thank you very much.

The following codes are from 2009 thread “How to add image from URL to slide”

VB.NET

'Source presentation to get the linked picture from
Dim srcPres As Presentation = New Presentation("c:\test\source.ppt")

'Source slide with a single shape which is a linked pictureframe
Dim srcSld As Slide = srcPres.GetSlideByPosition(1)

'Serialize the pictureframe
Dim shp As Shape = srcSld.Shapes(0)
Dim ms As MemoryStream = New MemoryStream()
shp.Serialize(ms)

'Now once serialized, we can import into our target presentation
'Create a target presentation
Dim target As Presentation = New Presentation()
Dim targetSld As Slide = target.GetSlideByPosition(1)

'Import the serialized shape
ms.Position = 0
targetSld.Shapes.Add(ms)

'Access the shape as a pictureframe
Dim pf As PictureFrame = CType(targetSld.Shapes(0), PictureFrame)

'Change its link path
pf.PictureFileName = "http:\\www.aspose.com/Images/aspose-logo.jpg"

'Write the target presentation on disk.
target.Write("c:\test\output.ppt")

Hi Bosco,

Thank you for the details.

You can try the following sample code to add an image from a URL to a Slide in your presentation file using Aspose.Slides for .NET v14.10.0.

'Instantiate Presetation class that represents the PPTX
Using pres As New Presentation()

    'Get the first slide
    Dim sld As ISlide = pres.Slides(0)

    'Add autoshape of rectangle type
    Dim shp As IShape = sld.Shapes.AddAutoShape(Aspose.Slides.ShapeType.Rectangle, 50, 150, 75, 150)

    'Set the fill type to Picture
    shp.FillFormat.FillType = FillType.Picture

    'Set the picture fill mode
    shp.FillFormat.PictureFillFormat.PictureFillMode = PictureFillMode.Stretch

    'Set the picture
    shp.FillFormat.PictureFillFormat.Picture.LinkPathLong = “http:\www.aspose.com/Images/aspose-logo.jpg”

    'Write the PPTX file to disk
    pres.Save(“d:\data\RectShpPic.pptx”, Aspose.Slides.Export.SaveFormat.Pptx)

End Using

In case you need any further assistance, please feel free to contact support.

Thanks & Regards,

It works. Thank you very much.

Hi Bosco,

Thank you for the feedback.

I am glad to know that your issue is resolved at your end.

Thanks & Regards,