Free Support Forum - aspose.com

Using SVG in presentation

Hi Guys,
I am trying to use the SVG import of Aspose.Slides (version 18.9.0).
I got an error message. Enclosed my example code.
UseSVGSample.zip (124.8 KB)
I have not indicated my total license for this example.

Thank you for your support.

@moosbart,

I have observed your comments. Can you please share source files so that we may further investigate to help you out.

Hello,
I attached the source code in a sample in my first post.
They just have to compile and start them.
Then you see my problem.
It is a dotnet core 2.1 application.

Thank you

@moosbart,

I have observed the sample code shared by you and it seems fine. However, I am unable to find source SVG file that is reproducing issue on your end. Please share the requested information so that we may proceed further to investigate the issue on our end.

Hello,
The SVG file was generated by Aspose.Cells

workBook.Save(svgPath, SaveFormat.SVG);

In the following line the error is thrown.

var emfImage = pres.Images.AddFromSvg(svgContent);

The Images object is initalized. But i become the following Message:
“Object reference not set to an instance of an object.”

This error should actually occur with everyone.

Thanks for your support.

@moosbart,

I have worked with your sample project and like to share that there is issue when you are generating SVG for workbook. You can create SVG of worksheet rather than workbook and for this reason the issue was arising. Please try using following sample code on your end.

    public static void TestSvgInsert()
    {

        String path=@"C:\Aspose Data\";
        
        var workBook = new Workbook();
        workBook.Worksheets[0].Cells["A1"].Value = "DEMOTEXT";

        // Access first worksheet
        Worksheet worksheet = workBook.Worksheets[0];

        // Access first chart inside the worksheet
       // Aspose.Cells.Charts.Chart chart = worksheet.Charts[0];

        // Set image or print options
        Aspose.Cells.Rendering.ImageOrPrintOptions opts = new Aspose.Cells.Rendering.ImageOrPrintOptions();
        opts.SaveFormat = Aspose.Cells.SaveFormat.SVG;


        SheetRender sr = new SheetRender(worksheet, opts);
        // Render the image for the sheet
        sr.ToImage(0, path + "SheetImage.out.svg");

        var pres = new Presentation();
        var svgContent = File.ReadAllText(path + "SheetImage.out.svg");
        //here comes a error
        var emfImage = pres.Images.AddFromSvg(svgContent);
        pres.Save(path+"SaveSbg.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
    }

I have tested the code and it works. :slight_smile:
My problem is solved.
Thank you so much.