Text Is Moved when Converting SVG to EMF in PowerPoint Presentation in Java

Hello Team,

When we insert Chart SVG into a PPT Slide using the below logic programmatically, the text does not render correctly after saving the document as PPTX file. While, when the same SVG is inserted into a PowerPoint Slide using the “Insert Pictures” option, the text gets rendered correctly.
This text rendering issue occurs only with Slides library whereas while performing the same use case with Words library it works fine. We are inserting the SVG into PowerPoint Slide after converting it to EMF image, since inserting SVG image as is into the Slide generates a PNG image copy as well within the PowerPoint document which increases the size.

Code used for inserting SVG into PowerPoint slide:

public void insertSvgIntoSlide() {
    IPresentation pres = PresentationFactory.getInstance().createPresentation();
    try {
        Path svgPath = Paths.get("HorizontalChart.svg");
        byte[] svgBytes = Files.readAllBytes(svgPath);
        String svgContent = new String(svgBytes, StandardCharsets.UTF_8);

        // Add SVG image to temp slide and extract EMF binary data from it
        IPresentation tempPres = PresentationFactory.getInstance().createPresentation();
        ISvgImage svgImage = new SvgImage(svgContent);
        IPPImage emfImage = tempPres.getImages().addImage(svgImage);
        byte[] emfBytes = emfImage.getBinaryData();

        // Now, add the extracted EMF bytes to original slide
        ISlideCollection slides = pres.getSlides();
        IPPImage ppImage = pres.getImages().addImage(emfBytes);
        slides.get_Item(0).getShapes().addPictureFrame(ShapeType.Rectangle, 50, 50,
                ppImage.getWidth(), ppImage.getHeight(), ppImage);
        pres.save("HorizontalChart.pptx", SaveFormat.Pptx);
    } catch (Exception e) {
        throw new IllegalStateException(e);
    } finally {
        if (pres != null) pres.dispose();
    }
}

Code used for inserting SVG into Word Document:

public void insertSvgIntoWord() {
    try {
        Path svgPath = Paths.get("HorizontalChart.svg");
        byte[] svgBytes = Files.readAllBytes(svgPath);
        String svgContent = new String(svgBytes, StandardCharsets.UTF_8);
        HtmlLoadOptions options = new HtmlLoadOptions();
        options.setConvertMetafilesToPng(false);
        Document document = new Document();
        DocumentBuilder builder = new DocumentBuilder(document);
        builder.insertImage(svgBytes);
        doc.save("HorizontalChart.docx");
    } catch (Exception e) {
        throw new IllegalStateException(e);
    }
}

Attachment: Horizontal Chart Text Not Rendered Correctly.zip (140.8 KB)

@oraspose,
Thank you for reporting on the issue. I’ve reproduced the problem you are experiencing.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): SLIDESJAVA-39306

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Hello @andrey.potapov, thanks for the confirmation. We will monitor this thread for any status update. Have a good day.

@oraspose,
Thank you for using Aspose.Slides.

Hi Team,

Any update on the bug status?

@oraspose,
I’ve requested ETA for the issue from our developers and will inform you as soon as possible.

@oraspose,
The issue has been planned to be fixed in Aspose.Slides for Java 23.11. This version will be published in the second half of November, and you will be notified. Thank you for your patience.

@andrey.potapov Thanks for the update.

@oraspose,
Thank you for using Aspose.Slides.

The issues you have found earlier (filed as SLIDESJAVA-39306) have been fixed in this update. This message was posted using Bugs notification tool.