Andy Thomas Andy Thomas - 1 month ago 12
Java Question

How to clip PowerPoint graphics using Apache POI with XSLF API

I'm trying to convert a Eclipse Draw2D Figure to a PowerPoint page by implementing

with Apache POI's XSLF API.

Apache POI's HSLF API supports a similar approach for AWT drawing, implementing
with HSLF class

The base graphics classes for both AWT and Draw2D provide methods to clip subsequent drawing. This is highly useful when drawing part of a larger scene.

The Apache POI implementation of the AWT graphics methods to set the clipping region is to log a warning. This suggests that it might not be feasible to clip arbitrary drawing in a PowerPoint page. So too does the apparent lack of controls for setting such clipping within the PowerPoint application itself.


A) Is clipping feasible in PowerPoint documents?

B) If so, how can clipping be requested through Apache POI?'

C) If not, what are possible workarounds?


In my case, I have adjacent columns that each need to be clipped. Laying big background-colored rectangles over the margins isn't sufficient.


Please have a look at - I might remove the PPGraphics2D class in the not so far future.

A) I think it's not such an big issue, I've did some rudimentary clipping in Graphics2d context for JasperReports

B) maybe via opening a feature request ;)

C) The workaround is to extend SLGraphics (preferably) or PPGraphics2D, but you basically would need to include the clipping in all drawing calls, i.e. clip all shapes.