Hello
I am Ritwik currently working on presentation module for a
product which needs creating a new presentation from two different
presentations.
What I am currently doing is:
1. Creating two slide shows for both the PPTs. (here we will add
desired slide of 2nd PPT at the end of 1st)
2. for each slide in the 2nd PPT
* Extract text out of textboxes, format it as its was in the
previous slide
* Extract auto shapes
* Extract lines
* Extract pictures
3. Add the extracts by creating new slide at end of PPT1.
SlideShow ppt1 = new SlideShow(input stream of 1st ppt);
SlideShow ppt2 = new SlideShow(nput stream of 2nd ppt);
Slide slide[] = ppt2.getSlides();
for(int i=0; i< slide.length; i++)
{
Slide newSlide = ppt1.createSlide();
newSlide.setFollowMasterBackground(true);
TextRun textRun[] = slide[i].getTextRuns();
Shape sh[] = slide[i].getShapes();
for (int j = 0; j < sh.length; j++)
{
//shapes's anchor which defines the position of this shape
in the slide
java.awt.Rectangle anchor = sh[j].getAnchor();
if (sh[j] instanceof Line)
{
Line line = (Line)sh[j];
Line newLine = new Line();
newLine.setAnchor(anchor);
newLine.setLineColor(line.getLineColor());
newLine.setLineStyle(line.getLineStyle());
newSlide.addShape(newLine);
}
else if (sh[j] instanceof AutoShape)
{
AutoShape shape = (AutoShape)sh[j];
shape.setAnchor(anchor);
newSlide.addShape(shape);
}
else if (sh[j] instanceof TextBox)
{
TextBox shape = (TextBox)sh[j];
TextBox txt = new TextBox();
txt.setText(textRun[j].getText());
txt.setAnchor(anchor);
RichTextRun rt =
shape.getTextRun().getRichTextRuns()[0];
RichTextRun newRt =
txt.getTextRun().getRichTextRuns()[0];
newRt.setFontSize(rt.getFontSize());
newRt.setFontName(rt.getFontName());
newRt.setBold(rt.isBold());
newRt.setItalic(rt.isItalic());
newRt.setUnderlined(rt.isUnderlined());
newRt.setFontColor(rt.getFontColor());
newRt.setAlignment(rt.getAlignment());
newSlide.addShape(txt);
}
else if (sh[j] instanceof Picture)
{
Picture pict = (Picture)sh[j];
PictureData pictData = pict.getPictureData();
byte[] data = pictData.getData();
int type = pictData.getType();
int id =ppt1.addPicture(data,type);
Picture pict1 = new Picture(id);
//set image position in the slide
pict1.setAnchor(anchor);
newSlide.addShape(pict1);
}
}
}
In short we need to clone the slides of 2nd PPT, so is there any easier and
efficient method to clone required slides of a PPT ???
Because currently I am facing following issues:
* Copy the TABLE from one PPT to another
* To recognize BULLET LIST and NUMBERED LIST and reproduce it as such
Thanking you,
Ritwik Kumar