Image is cropped on converting a GroupShape to an Image via WriteAsSVG (C# .NET)

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

@toddp4p,

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

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)

@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.

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

@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.

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

/;lkjhygfjghnoijk;lm, m,n ,mn

? Your reply is unreadable.
Thanks

@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.

Hi Mudassir,
Any Progress on this issue?
Thanks

@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.

@toddp4p,

I like to inform that we have investigated issue on our end and i like to inform that after you set scale size more than 100%, Windows scaling user interface using the appropriate DPI. Since this DPI is not available to Aspose.Slides, the size of the graphic elements is distorted. To avoid this you may explicitly let your application to know that you can handle higher DPI settings by adding the element to your manifest. Do next steps to add manifest to your project: Project + Add New Item, pick “Application Manifest File”. Edit the manifest text or copy/paste xml data which i shared in a file. Please check attachment. You can also invoke SetProcessDPIAware() in your New() method:

Public Class frmMain
<DllImport(“user32.dll”, SetLastError:=True)>
Private Shared Function SetProcessDPIAware() As Boolean
End Function

Public Sub New()

    ' This call is required by the designer.
    InitializeComponent()

    ' Add any initialization after the InitializeComponent() call.
    SetProcessDPIAware()
End Sub

…

End ClassWorkaround.zip (486 Bytes)