We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Link and text rendering when saving PPTX to SVG

Hi

We’re assessing whether Slides would be suitable for converting PowerPoint to SVG. An issue we’re running into is the quality of hyperlinks.

We are using the code from https://docs.aspose.com/display/slidesjava/Rendering+a+Slide#RenderingaSlide-GeneratinganSVGImagefromaSlide

What we’re seeing is the following:

  • Text tspans are getting a textLength attribute:

    <xlink:href="#category-472"><tspan x=“9.375” y=“21.96484” textLength=“69.625” font-family=“Verdana” fill="#FFFFFF">Case studies</tspan></a>

  • The underline for the hyperlink is being created as a separate path:

    <path fill="#FFFFFF" d=“M11 41.76L11 41.76 154.75 41.76 154.75 42.76 11 42.76z”></path>

If the SVG is embedded in a page and scaled, this leads to poorly laid out text and often the underline not matching up to the text.

What would be ideal would be if the following could happen:

  • Add an option to com.aspose.slides.SVGOptions to control whether the textLength is added to text
  • Add an option to com.aspose.slides.SVGOptions to control whether an underline is drawn (as per the current behaviour) or if a CSS class is used. If the CSS class is used, then add a class onto the text/tspan element:
    <xlink:href="#category-472"><tspan x=“9.375” y=“21.96484” class=“aspose_underline” font-family=“Verdana” fill="#FFFFFF">Case studies</tspan></a>
  • Add a style element into the SVG with the following:
    <style type=“text/css”>.aspose_underline{text-decoration:underline}</style>

The benefits of using classing is that the SVG would become smaller, the underlines would be more accurate and the end user could apply their own style overrides if need be. BTW - this would also be a really useful option in Diagram vsdx->svg.

Regards
Vittal

@vittala,

I have observed the issues mentioned by you and request you to please try using latest Aspose.Slides for Java 20.4 on your end. In case there is still an issue then please share the source file, generted output,. desired output and detail of issue incurring on your end.

Hi

Attached is a zip containing the following:

  • test.pptx - source PowerPoint
  • test-from-aspose.svg - SVG build with Aspose Java 20.4 and the example save as SVG
  • test-with-classing.svg - what we’d like to see. No textLength set on the tspans, no <path> elements in the parent <g> for the underlines, but this done with the “aspose_link” class and <style> element inserted at the start of the SVG

If this could be controlled via an SVGOptions setting, that would be great.

Regards
Vittal
Regards
Vittal

test-for-aspose.zip (26.8 KB)

@vittala,

I have observed both SVG files. Can you please share what how is second test-with-classing.svg is generated. It will be appropriate, if you may please provide the requirements or issue you are facing in the form of opened SVG data and highlighting the difference between Aspose.Slides generated SVG or any other tool generated SVG. Please also share the source code used too as I will be needing this to log investigation ticket.

Hi

The test-with-classing.svg was manually generated with what we’d ideally like to see.

To generate the SVG from Aspose Slides, we used the code at https://docs.aspose.com/display/slidesjava/Rendering+a+Slide#RenderingaSlide-GeneratinganSVGImagefromaSlide

Regards
Vittal

@vittala,

As requested earlier, can you please share following information.

Attached is the source pptx, the source code used to generate testshape-from-aspose.svg and an svg for the same file saved with PowerPoint itself.

However, the test-with-classing.svg was an SVG hand created with an idealized use of CSS rather than putting all the font details in the text elements themselves. Using CSS is makes for a lighter SVG, an easier to manipulate SVG and improves rendering.

Archive.zip (30.0 KB)

Regards
Vittal

@vittala,

I have seen the two SVG files (1 generated using Aspose.Slides and other using PowerPoint). Can you please highlight the difference and requirement that out ought to fulfill using Aspose.Slides.

Hi

There are a number of issues:

  1. On the tspan elements, aspose uses the textLength attribute. This is not exported by Powepoint and we find it can lead to some odd rendering
  2. The underline for the link is drawn as a path element. We find that the underline and the text don’t always marry up. What would be useful is for the text in the link and the path both to have a CSS class. That way we could hide the path underlines and add text underlines using pure CSS for a more accurate representation.
  3. It would make for smaller resulting SVG files if text elements could have CSS classes rather than using the font attributes. The benefit also being that the classes can potentially be overridden by the end-user’s own CSS.

Regards
Vittal

@vittala,

I have created an issue with ID SLIDESJAVA-38177 in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be addressed.

Hi - is there any progress on this issue?

@vittala,
I requested some estimated time to fix the issue from our development team. I will let you know as soon as possible.

@vittala,
The estimated time to fix this issue is 2021’Q3, but there is a chance for Aspose.Slides 21.7.