Besides, the reason I come up with this question is in a pptx i generated, i would like to adopt the other ppt's pattern and masterview.
However, when I parse the sldMaster node, the doc will not be opened.
Then I'm thiking if I could load a slides in and add content, however, I could no loaded those pptx.
Is there any way to meed my need?
Thx.
- Code: Select all
MainPresentationPart pp = new MainPresentationPart();
pp.setJaxbElement(MainPresentationPart.createJaxbPresentationElement() );
presentationMLPackage.addTargetPart(pp);
// Slide Master part
SlideMasterPart masterPart = new SlideMasterPart();
pp.addSlideMasterIdListEntry(masterPart);
masterPart.setJaxbElement((SldMaster) XmlUtils.unmarshalString(sldMaster4, Context.jcPML));
// masterPart.setJaxbElement(masterPart.createSldMaster() );
// Slide layout part
SlideLayoutPart layoutPart = new SlideLayoutPart();
layoutPart.setJaxbElement( SlideLayoutPart.createSldLayout() );
masterPart.addSlideLayoutIdListEntry(layoutPart);
layoutPart.addTargetPart(masterPart);
// Theme part
ThemePart themePart = new ThemePart(new PartName("/ppt/theme/theme1.xml"));
java.io.InputStream is = org.docx4j.utils.ResourceUtils.getResource(
"org/docx4j/openpackaging/parts/PresentationML/theme.xml");
themePart.unmarshal(is);
// .. add it in 2 places ..
masterPart.addTargetPart(themePart);
pp.addTargetPart(themePart);
// OK, now we can create a slide
SlidePart slidePart = presentationMLPackage.createSlidePart(pp,
layoutPart, new PartName("/ppt/slides/slide1.xml"));
SlidePart slidePart2 = presentationMLPackage.createSlidePart(pp,
layoutPart, new PartName("/ppt/slides/slide2.xml"));