Page 1 of 1

can't create multiple slides with for statement

PostPosted: Thu May 07, 2015 1:09 pm
by Andre d docx4j
I am trying to create a list of objects of pptx4j slides based on the http://www.docx4java.org/svn/docx4j/trunk/docx4j/src/pptx4j/java/org/pptx4j/samples/CreateHelloWorld.java and i have tried modifying it so instead of printing one slide it can print as many as i want by adding a little for loop that creates each slide so i tried doing a for loop that repeats this for each slide but i don't know how to create the objects and adding them to the array, i tried adding the object directly but it gives me errors, this is my for:

Code: Select all
ArrayList<Object[]> lista =new ArrayList<>();
   Object[] diapositivas = new Object[3];
   for (int i=0;i<3;i++){       
      diapositivas[i] =(SlidePart) presentationMLPackage.createSlidePart(pp, layoutPart,
      new PartName("/ppt/slides/" + [i + 1] + ".xml"));
      Shape sample = ((Shape)XmlUtils.unmarshalString(SAMPLE_SHAPE, Context.jcPML) );
      diapositivas[i] =diapositivas[i].getJaxbElement().getCSld().getSpTree().getSpOrGrpSpOrGraphicFrame().add(sample);
      lista.add(diapositivas);
     }


what am i doing wrong here? how can i create several slides that say hellow world in the same file?

Re: can't create multiple slides with for statement

PostPosted: Thu May 07, 2015 9:09 pm
by jason