Bug 62365 - SVG image support in XSLF
Summary: SVG image support in XSLF
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: XSLF (show other bugs)
Version: 4.0.x-dev
Hardware: PC All
: P2 enhancement (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-05-10 05:29 UTC by Ritesh Sood
Modified: 2018-12-16 21:03 UTC (History)
0 users



Attachments
Simple application to generate slidedeck and supporting files (343.43 KB, application/x-gzip)
2018-05-10 05:29 UTC, Ritesh Sood
Details
Patch to add SVG image support to XSLF. (16.30 KB, patch)
2018-05-13 08:01 UTC, Ritesh Sood
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ritesh Sood 2018-05-10 05:29:55 UTC
Created attachment 35924 [details]
Simple application to generate slidedeck and supporting files

Feature request to add SVG image support. This is the only way of including vector graphics in a .pptx that is valid across platforms. Other vector graphics formats are valid on windows (EMF, PDF) but not on linux (EPS).
Comment 1 Ritesh Sood 2018-05-13 08:01:48 UTC
Created attachment 35933 [details]
Patch to add SVG image support to XSLF.

Patch to add SVG image support to XSLF. A PNG version of the image is also created using Batik and included in the slidedeck. I've verified the output on Windows where the SVG is displayed, and on linux and MacOS where the PNG is displayed. The code I've added is really a hack and is far from production quality. Submitting this patch just in case its useful to someone doing real development on this feature.
Comment 2 Andreas Beeker 2018-05-13 10:48:47 UTC
Thank you for sharing your code.

I just had a glimpse on it, as I'm busy fixing a regression on #53176.
As we usually try to minimize dependencies (to Batik), I'll try to encapsulate the svg-rendering, e.g. by providing a preview picture when adding the svg or by implementing the ImageRenderer (see BitmapImageRenderer) on rendering the slides.
Comment 3 Michael Kendra 2018-12-13 02:23:10 UTC
Hi Andreas, Ritesh.
Comment 4 Michael Kendra 2018-12-13 02:24:50 UTC
Was wondering what is the status of this patch? It would be awesome to have native SVG support through POI. As currently we need to rasterize vectors to pngs.

If there's something I can do to help push this along please let me know. Otherwise, thanks for the support and development of this library
Comment 5 Andreas Beeker 2018-12-13 07:14:50 UTC
(In reply to Michael Kendra from comment #4)
> As currently we need to rasterize vectors to
> pngs.


SVG support in Office is relatively new ... If those pictures are in EMF format, you might want to check the emf branch. I've done some modifications there on how the renderers are executed, so I'll merge that first before careing about the SVG enhancement.

I think it's OK to compile against Batik, but then omit the jar/reference in our dist. But we need to make sure, that a missing reference is handled gracefully.
Comment 6 Andreas Beeker 2018-12-16 15:10:42 UTC
Partly implemented via r1849030

You can add a SVG image on top of a preview image via XSLFPictureShape.setSvgImage() or use the convenience method XSLFPictureShape.addSvgImage().

See also the junit test renderSvgImage() in http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFPictureShape.java?view=markup

I need to merge the EMF branch first, which contains a different image renderer loading, before the slide rendering works - currently only adding the svg image (incl. thumbnail generation) works.

I omitted the dependency to batik-all ("-all", because nearly all batik modules are need), xml-apis-ext and xmlgraphics-commons in the dist files as I consider this not as a core feature and it's easy for users to add batik-all to their maven/gradle build ...

I'll add a note to the component overview.
Comment 7 Andreas Beeker 2018-12-16 21:03:02 UTC
Added the slide rendering via r1849046