Text Is Not Underlined 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 underlined 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 underlined text gets rendered correctly.
This underline issue occurs only with Slides library while when performing the same usecase with Words library it works fine. We are inserting the SVG into Slide after converting it to EMF image, since inserting SVG image as is generates a PNG image 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("ChartWithUnderLinedText.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, 0, 0,
                ppImage.getWidth(), ppImage.getHeight(), ppImage);
        pres.save("ChartWithUnderLinedText.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("ChartWithUnderLinedText.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("ChartWithUnderLinedText.docx");
    } catch (Exception e) {
        throw new IllegalStateException(e);
    }
}

Attachments:ChartWithUnderLinedText.zip (39.8 KB)

@oraspose,
Thank you for reporting on the issue. I’ve reproduced the problem with the underlined text.

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-39302

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.

Thanks for the information. We will follow this thread closely for any ticket update.

@oraspose,
Thank you for using Aspose.Slides.

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