Issue with Converting a GroupShape to an Image via WriteAsSVG


#1

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

#2

@toddp4p,

Can you please share source file along with generated result so that we may further investigate to help you out.


#3

Yes,
Here are 3 Presentations.

  1. The original one to be converted (it has the group shapes in it) - called “PresOriginal”.
  2. The one converted with the screen display settings at 100% which works - called “PresResultCORRECTAt100PercentScreenRes”
  3. The one converted with the screen display settings at 150% which doesn’t work - called "PresResultProblemAt150percentScreenRes"GroupConversionIssuePresentations.zip (5.2 MB)

#4

@toddp4p,

I have observed the issue details along with source files as well. In your code, you are using following method:

 myAgroup = RegroupAgroup(myAgroup)

I have not found definition of this method in your provided code. I also suggest you to please try commenting following line in your code too as you are already setting the image width and height while adding PictureFrame.

                   myPicFrame.Width = myGroupWidth
                            myPicFrame.Height = myGroupHeight

If there is still an issue then please share the working sample project that we may use on our end to verify the issue and helping you further.


#5

Sorry for the delay on this, I have been out of town. I have a complete project that highlights the issue I am having at this link: https://spaces.hightail.com/receive/BKsRhNdZ2G. It works great as long as the computer’s display settings “Scale and layout” is set to 100%. If you increase it, the resulting picture has additional transparent space around it.
Thanks,
Todd


#6

@toddp4p,

I have observed your comments. A ticket with ID SLIDESNET-41237 has been created in our issue tracking system to investigate this issue in detail. This thread has been associated with the ticket so that we may share the notification with you once investigation will be completed.


#7

Hello Adnan.Ahmad - Is there any progress on this issue?
Thanks,
Todd


#8

/;lkjhygfjghnoijk;lm, m,n ,mn


#9

? Your reply is unreadable.
Thanks


#10

@toddp4p,

I have verified from our issue tracking system and like to share that the issue is in progress and we will share good news with you as soon as the issue will be fixed.


#11

Hi Mudassir,
Any Progress on this issue?
Thanks


#12

@toddp4p,

I like to inform that this issue will be resolved soon. The tentative ETA is Aspose.Slides 19.7. I request for your patience.