Below is the same code in JAVA. It has the same output, you can see the output presentation and source presentation from the post above, they are attached there.
JAVA CODE
----------------------------------------------------------------------------------------------------------------------
public static void main(String[] args) {
try
{
Presentation srcPres = new Presentation(new FileInputStream("c:\\srcPres.ppt"));
Presentation dstPres = new Presentation();
CloneSlideWithNotes(srcPres, 1, dstPres);
dstPres.write(new FileOutputStream("c:\\dstPres.ppt"));
}
catch(Exception ex)
{
System.out.println(ex.toString());
}
}
public static void CloneSlideWithNotes(Presentation srcPres, int srcSlidePosition,
Presentation dstPres) throws Exception
{
Slide srcSld;
srcSld = srcPres.getSlideByPosition(srcSlidePosition);
if (srcSld == null)
return;
int dstSldPosition;
dstSldPosition = dstPres.getSlides().getLastSlidePosition() + 1;
//Clone slide now, we have all the necessary parameters
Slide dstSld;
dstSld = srcPres.cloneSlide(srcSld, dstSldPosition, dstPres, new TreeMap());
//Now below is the code to copy srcSld notes to dstSld notes
//Check if the source slide has notes
if(srcSld.getNotes()==null)
return;
//Add notes to dstSld and clear all paragraphs
dstSld.addNotes();
Paragraphs dstNotesParas=dstSld.getNotes().getParagraphs();
dstNotesParas.clear();
//Finally add all the pargraphs in notes of sldSrc into the notes of dstSld
Paragraphs srcNotesParas=srcSld.getNotes().getParagraphs();
int parasCount=srcNotesParas.size();
for(int i=0; i<parasCount; i++)
{
Paragraph srcPara=srcNotesParas.get(i);
//Create the replica of srcPara
Paragraph dstPara=new Paragraph(srcPara);
//Add this Replica to dstSld.Notes.Paragraphs
dstNotesParas.add(dstPara);
}//for
}
Many Thanks and Kind Regards,
Shakeel Faiz
Support Engineer
Aspose Tyumen Team