Bug 60625 - Rendering issue with background and shape overlayed by image
Summary: Rendering issue with background and shape overlayed by image
Alias: None
Product: POI
Classification: Unclassified
Component: XSLF (show other bugs)
Version: 3.16-dev
Hardware: PC Mac OS X 10.1
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2017-01-23 00:20 UTC by Johanes Soetanto
Modified: 2017-02-14 00:42 UTC (History)
0 users

sample of result from slide 2 and 16 that have issue (160.70 KB, application/xhtml+xml)
2017-01-23 00:20 UTC, Johanes Soetanto

Note You need to log in before you can comment on or make changes to this bug.
Description Johanes Soetanto 2017-01-23 00:20:55 UTC
Created attachment 34662 [details]
sample of result from slide 2 and 16 that have issue


We are having problem to use POX XSLF with rendering background colour and rendering shape that overlayed by transparent image?

We test our code to render http://www.slideshare.net/sdeeg/spring-boot into image/svg but 
- the background is rendered as grey instead of white. 
- a rectangular shape that placed behind a PNG image is rendered. In this case can be argued that part of shape is behind the PNG image but some of them only behind transparent section of the image, but Powerpoint and Keynote application do not render them

POI 3.16-beta1
Batik 1.7

Code to test:
String presentation = // your downloaded presentation file
String dir = "/tmp/" + UUID.randomUUID().toString();
XMLSlideShow ppt = new XMLSlideShow(new FileInputStream(presentation));
int i = 1;
for (XSLFSlide slide : ppt.getSlides())
    String filename = dir + "/slide-" + i + ".svg";
    org.w3c.dom.Document doc = org.apache.batik.dom.svg.SVGDOMImplementation.getDOMImplementation()
            .createDocument("http://www.w3.org/2000/svg", "svg", null);
    //Use Batik SVG Graphics2D driver
    SVGGeneratorContext svgContext = SVGGeneratorContext.createDefault(doc);
    SVGGraphics2D graphics = new SVGGraphics2D(svgContext, false);
    // draw stuff. All the heavy-lifting happens here
    // save the result.
    try (final OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(filename), "UTF-8"))
        graphics.stream(out, true);

I have tried to fix the background image but seems like setting up the fill colour is not the correct way to do. I also debug the drawing method for the layers for shape issue, i can see that the order of drawing is correct that the bottom most layer is rendered first but seems like the issue lay in the rectangular shape is rendered first without considering there is another image that have bounding rectangle on top of it (even though transparent).

If anyway can point out the correct direction to fix the issue going to be great.

Comment 1 Andreas Beeker 2017-01-23 00:57:11 UTC
I don't have a LinkedIn account to download something from slideshare ... and I refuse to register! ... and I don't want to spent more than 15 minutes on how to download the original .pptx without registration ...

If it's ok copyright-wise and size-wise, please upload that slideshow to bugzilla ... or if not, send it to my apache email.

Comment 2 Andreas Beeker 2017-01-24 07:47:03 UTC
The file is also available at [1] - I've seen a few rendering issues and try to cope with them (... hopefully soon ...)
As we've also uploaded files from tika runs, I probably will upload it also to our test corpus, 

[1] https://people.apache.org/~kiwiwings/spring-boot.pptx
Comment 3 Andreas Beeker 2017-02-08 01:21:25 UTC
fixed a few rendering issues with r1782096
and tested it with batik too
added support for slide numbers to XSLF/HSLF

you should add the wingding.ttf to awt for correct bullet rendering - at least with png output

please give it a try
Comment 4 Johanes Soetanto 2017-02-08 22:51:09 UTC
Hi Andreas,

I had a quick test from the nightly built yesterday and from my observation

What works:
- background colour issue is fixed
- the fix for the page works on PPTx export but appear as asterisk if exported from PPT file

What do not work:
- rectangle border still exist (slide-16.svg)
- (NEW) white background in the middle 1st page is not rendered (slide-1.svg) . This is quite weird issue, if I save the PPTx file into pre-2003 PPT format then the white background is rendered correctly. I also tested this one rendered correctly in 3.16-beta2 (samples in the link below)

Links: https://www.dropbox.com/sh/ir981cxkutmkxps/AADTcj17KwOnpm26JJBMjgj_a?dl=0
Comment 5 Andreas Beeker 2017-02-13 00:55:19 UTC
I've added a few more fixes via r1782706
and r1782712

Both XSLF (support for themes) and HSLF (support for shapes) still have quite a few problems ... I leave it up to you, to decide when to close the bug ... I probably close it before we push POI 3.16 final ...
Comment 6 Johanes Soetanto 2017-02-14 00:42:17 UTC
Thanks Andreas,

Seems like your latest fixes work for the main issue that I reported for this bug