简体   繁体   中英

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 org.eclipse.draw2d.Graphics with Apache POI's XSLF API.

Apache POI's HSLF API supports a similar approach for AWT drawing, implementing java.awt.Graphics2D with HSLF class org.apache.poi.hslf.model.PPGraphics2D .

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.

Questions:

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?

Notes:

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 org.apache.poi.sl.draw.SLGraphics - 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, ie clip all shapes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM