Converting Single Shape within Presentation to PDF possible?

Hello I am using Aspose Slides Java Component 15.7.0

Can i export single Shape Object within Presentation to PDF/HTML format ? Or I need to create new presentation object for that Shape Object and then save it using Presentation object's save method.

Is there any direct API for converting Shape Objects to PDF/Html format.

Regards
Shubhi Sood

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.

Hi Shubhi,

Thank you for posting.

I have observed your comments and like to share with you that a shape can not be converted into PDF directly however an alternative approach could be to clone a shape from one presentation to another and then conversion to PDF. You can search for a specific shape using alternative text of shape as explained in this documentation article and then you may clone a specific shape as explained there. Finally, you can convert resultant presentation to PDF.

I help this will be helpful. Please share if I may help you further in this regard.

Best Regards,