PresentationMLPackage presentationMLPackage = PresentationMLPackage.createPackage();
// Need references to these parts to create a slide
// Please note that these parts *already exist* - they are
// created by createPackage() above. See that method
// for instruction on how to create and add a part.
MainPresentationPart pp = (MainPresentationPart)presentationMLPackage.getParts().getParts().get(
new PartName("/ppt/presentation.xml"));
SlideLayoutPart layoutPart = (SlideLayoutPart)presentationMLPackage.getParts().getParts().get(
new PartName("/ppt/slideLayouts/slideLayout1.xml"));
PresentationPropertiesPart presProp = (PresentationPropertiesPart)presentationMLPackage.getParts().getParts().get(
new PartName("/ppt/preseProps.xml"));
// OK, now we can create a slide
SlidePart slidePart = presentationMLPackage.createSlidePart(pp, layoutPart,
new PartName("/ppt/slides/slide1.xml"));
// Create and add shape
Shape sample = ((Shape)XmlUtils.unmarshalString(SAMPLE_SHAPE, Context.jcPML) );
slidePart.getJaxbElement().getCSld().getSpTree().getSpOrGrpSpOrGraphicFrame().add(sample);
// All done: save it
presentationMLPackage.save(new java.io.File(outputfilepath));
System.out.println("\n\n done .. saved " + outputfilepath);
i have used above CreateHelloworld.java example to create a pptx document . I have modified it so that the created pptx package has presProps.xml. But it is not generated when i execute the above code….Any help will be appreciated
As per the comment at the top of code you have copy/pasted, your code assumes the PresentationPropertiesPart already exists.
It doesn’t, so you have to create it first. The following ought to do the trick: