I have Aspose Slides and have almost completed my project but I have a problem when the computer display is set to more than 100% text scaling. I have tried many options and none seem to help when creating an SVG image from a group and then putting it back in the presentation as a picture in a picture frame. If the display is set to 100% it works great but if it’s larger, the image has empty space on the right and bottom of the image. I even tried cropping the picture frame (right and bottom) but the crop doesn’t work. I checked in debug mode) to see that the CropBottom and left were set and they are set to .334 on a 150% screen scale but the image seems to ignore the crop setting.
The code snippet below works great when the display is set to 100%. It opens a presentation template with my GroupShapes (each of which consist of a text box, a bubble shape with text, and several pictures). It exports the group to a memory stream in SVG format and then loads the svg image back into the presentation in a PictureFrame, renames the new PictureFrame to the original GoupFrame name substituting “grp” for “pic”, resizing the new PictureFrame to the size and position of the original GroupShape, deletes the GroupShape from the slide, and then saves the new presentation.
Thank You!
Imports Asp = Aspose.Slides
Sub SaveMSGroupsAsPicture(myPPtPathAndFile as String)
Dim myAPres As Asp.Presentation = New Asp.Presentation(myPPtPathAndFile)
Dim myAslide As Asp.Slide
Dim myMemStream As MemoryStream
Dim mySvgImage As Asp.SvgImage
Dim myImages As Asp.ImageCollection
Dim myImage As Asp.PPImage
Dim myPicFrame As Asp.PictureFrame
Try
Dim myGroupNameTxt1 As String = "grpMS"
Dim myGroupNametxt2 As String = "Scen"
If myAPres IsNot Nothing Then
Dim myAshape As Asp.Shape
Dim myAgroup As Asp.GroupShape
Dim myGroupWidth As Single
Dim myGroupHeight As Single
For mySlideIndex As Integer = 1 To myAPres.Slides.Count
myAslide = myAPres.Slides(mySlideIndex - 1)
Dim myOldGroupList As New List(Of Integer)
For myGroupIndex As Integer = 0 To myAslide.Shapes.Count - 1
myAshape = myAslide.Shapes(myGroupIndex)
If InStr(myAshape.Name, myGroupNameTxt1) > 0 Then
If InStr(myAshape.Name, myGroupNametxt2) > 0 Then
myAgroup = myAshape
myGroupWidth = myAgroup.Width
myGroupHeight = myAgroup.Height
myAgroup = RegroupAgroup(myAgroup)
myMemStream = New MemoryStream()
myAgroup.WriteAsSvg(myMemStream)
myMemStream.Seek(0, SeekOrigin.Begin)
mySvgImage = New Asp.SvgImage(myMemStream)
myImages = myAPres.Images
myImage = myImages.AddImage(mySvgImage)
myMemStream.Dispose()
myPicFrame = myAslide.Shapes.AddPictureFrame(Asp.ShapeType.Rectangle, 100, 100, myImage.Width, myImage.Height, myImage)
myPicFrame.Name = "pic" & Strings.Right(myAgroup.Name, Len(myAgroup.Name) - 3)
myPicFrame.X = myAgroup.X
myPicFrame.Y = myAgroup.Y
myPicFrame.Width = myGroupWidth
myPicFrame.Height = myGroupHeight
myOldGroupList.Add(myGroupIndex)
End If
End If
Next
If myOldGroupList.Count > 0 Then
For myDeleteCount As Integer = myOldGroupList.Count - 1 To 0 Step -1
myAslide.Shapes.RemoveAt(myOldGroupList(myDeleteCount))
Next
End If
Next
End If