1

I would like to change the properties of .pptx files programatically using Apache POI. I am done with .docx and .pdf using Itext. When it comes for .pptx files the recommended package XLSF doesn't have any method to retrieve/change the properties of .pptx files. Rather there are methods to retrieve no of slides,datas etc. Can anyone help on this ?? Thanks in advance

Wolfgang Fahl
  • 15,016
  • 11
  • 93
  • 186
sreram
  • 99
  • 2
  • 9

1 Answers1

0

You'll want to take a look at the JavaDocs for XSLFSlideShow. From there, you'll see it has a method getProperties(). That returns a POIXMLProperties object, which lets you get at the three different kinds of properties that an OOXML file (such as .pptx) has - core, extended and custom.

Next, you'll need to work out what kind of properties the ones you want to change are. Assuming you wanted to change the title (a core property), you'd do something like:

OPCPackage pkg = OPCPackage.open("input.pptx");
XSLFSlideShow slideshow = new XSLFSlideShow(pkg);

POIXMLProperties props = slideshow.getProperties();
CoreProperties cp = props.getCoreProperties();
cp.setTitle("I changed the title!");

FileOutputStream out = new FileOutputStream("output.pptx");
slideshow.write(out);
out.close();
pkg.close();
Gagravarr
  • 47,320
  • 10
  • 111
  • 156