Page 1 of 1

Correct Way to Create a Slide

PostPosted: Tue Jul 13, 2010 1:28 am
by tmnt
Jason,

I was wondering what the correct way to add a slide to a presentation was. Sometimes powerpoint complains about corrupt or irretrievable data when I open a presentation I've added a slide to. This is usually the case when I try and use a layout other than slideLayout1. Is there an example I'm missing that demonstrates this?

Thanks,
Pablo

Re: Correct Way to Create a Slide

PostPosted: Tue Jul 13, 2010 10:55 pm
by jason
Hi Pablo

Code: Select all
PresentationMLPackage.createPackage()


creates slideLayout1:
Code: Select all
         // Slide layout part
         SlideLayoutPart layoutPart = new SlideLayoutPart();
         layoutPart.setJaxbElement( SlideLayoutPart.createSldLayout() );
         
         slidePart.addTargetPart(layoutPart);


If you want to use any other layout, you'll need to add it to the package in a similar way.

For it to be useful, you'll probably want to copy the contents of the layout part you want from an existing pptx file.

See the docx4j samples ImportForeignPart and CopyPart for hints as to how to do this.

If you can work up a pptx specific sample which i could add which shows how to add a layout from a layout part sitting in the file system, that'd be great :-)

hope this helps .. Jason

Re: Correct Way to Create a Slide

PostPosted: Fri May 12, 2017 2:05 am
by antoninpa
Thanks Jason for your answer, but how do you actually create the slide ?

Do you NEED to have a layout part ? It seems like the real arrangement of component sin a slide come from the slide's own xml ? The layout is only "linked" to the slide.

Re: Correct Way to Create a Slide

PostPosted: Fri May 12, 2017 3:03 pm
by jason