Free Support Forum - aspose.com

Missing SVG text in exported PPTX

Hi There,

I have a problem to add a SVG string with one text element to the Aspose.Slides GroupShapes.

The exported PPTX file is absolutely empty - it shows nothing…

...
var svgData = "<svg height='100' width='200'><text x='0' y='15' fill='red'>I love SVG!</text></svg>";
ISvgImage svgImage = new SvgImage(svgData);
IGroupShape groupShape = Slide.gSlide.Shapes.AddGroupShape(svgImage, 0, 0, 200, 100);
...

Can you help me ?

Thanks,
Marius W.

@Dejab,

I have observed your requirement and regret to share that what you are doing is not possible. The group shape is only a cluster or group of shapes. GroupShape it self is not a normal shape. You need to access a particular shape inside group shape collection and then add SVG to that. This is neither an issue nor a limitation of API.

@mudassir.fayyaz,

Thanks for your answer.

You need to access a particular shape inside group shape collection and then add SVG to that.

Can you give me an example to add something like that SVG to powerpoint ?

<svg height='100' width='200'><text x='0' y='15' fill='red'>I love SVG!</text></svg>

Thanks,
Marius W.

@Dejab,

I suggest you to please visit this documentation link for your kind reference.

@mudassir.fayyaz,

Thanks for you answer.

Okey i see there is no way to add text from a svg image to the slide with aspose.slides.

In Powerpoint ( Version 16.37 ) there is a way to convert an imported svg image to a group shape - with text ! ( Right click on the svg and click “convert to shapes…” ):
pptx.png (100.6 KB)

My example svg with multiple forms and texts in it:
test.svg.zip (21.2 KB)

Is there a similar function in Aspose.Slides to convert an imported svg to group shapes with texts ?

Thanks,
Marius W.

@Dejab,

In the example link that I have shared, its evident that SVG content is added as string. If you have file as SVG, you can read the file and convert to string. If you have a SVG string, you can directly add that in presentation Image collection.

There is no such option to import an SVG in group shape. As mentioned earlier, group shape is only a logical collection of shapes grouped together. This is neither a limitation nor an issue.

@mudassir.fayyaz,

@mudassir.fayyaz
In the example link that I have shared, its evident that SVG content is added as string. If you have file as SVG, you can read the file and convert to string. If you have a SVG string, you can directly add that in presentation Image collection.

When i use that way to add svg to the slide and then convert that image to a group Shape like in your documentation:

// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_PresentationSaving();

using (Presentation pres = new Presentation(dataDir+ "image.pptx"))
{
    PictureFrame pFrame = pres.Slides[0].Shapes[0] as PictureFrame;
    ISvgImage svgImage = pFrame.PictureFormat.Picture.Image.SvgImage;
    if (svgImage != null)
    {
        // Convert svg image into group of shapes
        IGroupShape groupShape = pres.Slides[0].Shapes.AddGroupShape(svgImage, pFrame.Frame.X, pFrame.Frame.Y,
            pFrame.Frame.Width, pFrame.Frame.Height);
        // remove source svg image from presentation
        pres.Slides[0].Shapes.Remove(pFrame);
    }

    pres.Save(dataDir + "image_group.pptx", SaveFormat.Pptx);
}

All texts are gone and missing that exists in the svg image… that’s my problem !
Powerpoint not remove texts by convert it to shapes like my example from above.

Here is a picture of the missing texts:

missing.png (31.7 KB)

Hope you can help me or create a ticket for it ?

Thanks,
Marius W.

@Dejab,

Can you please provide the source presentation file used in your sample code that I may use on my end to test your code and add ticket in our issue tracking system.

@mudassir.fayyaz,

My Code:

        string svgPath = "germany.svg";

        string svgContent = File.ReadAllText(svgPath);

        svgContent = Regex.Replace(svgContent, @"stroke-width='.*?'", "");

        ISvgImage svgImage = new SvgImage(svgContent);

        Presentation pres = new Presentation();

        IPPImage ppImage = pres.Images.AddImage(svgImage);

        IPictureFrame pFrame = pres.Slides[0].Shapes.AddPictureFrame(ShapeType.Rectangle, 0, 0, ppImage.Width, ppImage.Height, ppImage);

        IGroupShape groupShape = pres.Slides[0].Shapes.AddGroupShape(svgImage, pFrame.Frame.X, pFrame.Frame.Y, pFrame.Frame.Width, pFrame.Frame.Height);

        pres.Slides[0].Shapes.Remove(pFrame);

        pres.Save("export.pptx", SaveFormat.Pptx);

My SVG File:

germany.svg.zip (21.2 KB)

Thanks,
Marius W.

@Dejab,

Than you for sharing the information. An issue with ID SLIDESNET-41966 has been created in our issue tracking system to further investigate the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.