As per my understanding till now:
For converting a shape within slide to PDF we need to perform following steps:
1) Get the thumbnail of that shape from presentation (say pres) slide.
2)Save that thumbnail to a particular location.
3)Create a new Presentation say(presNew) and get its slide .
4)Add image saved earlier to presNew’s slide.
5)Keep on iterating and add each of the shape within a particular slide to a new presentation(presNew ).
6)Save that presentation(PresNew) to a particular location in the form of any of the supported file formats.
Snippet:
public File slideSmartArtToPdf2(Presentation pres, int slideIndex) {
ISlide slide = pres.getSlides().get_Item(slideIndex);
Presentation presNew = new Presentation();
int i = 0;
// Traverse through every shape inside first slide
for (IShape shape : slide.getShapes()) {
// Get the first slide of new presentation
ISlide sld = presNew.getSlides().get_Item(i);
IPPImage imgx = null;
// Check if shape is of SmartArt type
if (shape instanceof ISmartArt) {
BufferedImage image = shape.getThumbnail(
ShapeThumbnailBounds.Appearance, 1.0f, 1.0f);
try {
String shapeName = shape.getName();
File img = new File(“slides\smartArt” + shapeName + “.png”);
ImageIO.write(image, “png”, img);
// Add autoshape of rectangle type
IShape shp = sld.getShapes().addAutoShape(
ShapeType.Rectangle, 50, 150, 75, 150);
// Set the fill type to Picture
shp.getFillFormat().setFillType(FillType.Picture);
// Set the picture fill mode
shp.getFillFormat().getPictureFillFormat()
.setPictureFillMode(PictureFillMode.Tile);
// Set the picture
try {
imgx = pres.getImages().addImage(
new FileInputStream(new File(shapeName)));
} catch (IOException e) {
}
shp.getFillFormat().getPictureFillFormat().getPicture()
.setImage(imgx);
// Write the PDF file to disk
pres.save(“RectShpPic.pdf”, SaveFormat.Pdf);
i++;
} catch (IOException exp) {
exp.printStackTrace();
}
}
}
presNew.save(“presNew.pdf”, SaveFormat.Pdf);
return null;
}
Is there any way to convert Shape Object directly to PDF rather than copyingit to another presentation and save it.