Presentation Viewer

Live Example

You can try Aspose.Slides Viewer free app to see what you can implement with Aspose.Slides API:

todo:image_alt_text

Generate SVG Image from Slide

To generate an SVG image from any desired slide with Aspose.Slides for Android via Java, please follow the steps below:

  • Create an instance of the Presentation class.
  • Obtain the desired slide’s reference by using its ID or index.
  • Get the SVG image in a memory stream.
  • Save the memory stream to file.
// Instantiate a Presentation class that represents the presentation file
Presentation pres = new Presentation("CreateSlidesSVGImage.pptx");
try {
    // Access the first slide
    ISlide sld = pres.getSlides().get_Item(0);

    // Create a memory stream object
    FileOutputStream svgStream = new FileOutputStream("Aspose_out.svg");

    // Generate SVG image of slide and save in memory stream
    sld.writeAsSvg(svgStream);

    svgStream.close();
} catch (IOException e) {
} finally {
    pres.dispose();
}

Generate SVG with Custom Shape IDS

Aspose.Slides for Android via Java can be used to generate SVG from slide with custom shape ID. For that, use ID property from ISvgShape, which represents custom ID of shapes in generated SVG. CustomSvgShapeFormattingController can be used to set shape ID.

Presentation pres = new Presentation("pptxFileName.pptx");
try {
    FileOutputStream stream = new FileOutputStream("Aspose_out.svg");
    try {
        SVGOptions svgOptions = new SVGOptions();
        svgOptions.setShapeFormattingController(new CustomSvgShapeFormattingController());

        pres.getSlides().get_Item(0).writeAsSvg(stream, svgOptions);
    } finally {
        if (stream != null) stream.close();
    }
} catch (IOException e) {
} finally {
    pres.dispose();
}
class CustomSvgShapeFormattingController implements ISvgShapeFormattingController
{
    private int m_shapeIndex;

    public CustomSvgShapeFormattingController()
    {
        m_shapeIndex = 0;
    }
    
    public CustomSvgShapeFormattingController(int shapeStartIndex)
    {
        m_shapeIndex = shapeStartIndex;
    }

    public void formatShape(ISvgShape svgShape, IShape shape)
    {
        svgShape.setId(String.format("shape-%d", m_shapeIndex++));
    }
}

Create Slides Thumbnail Image

Aspose.Slides for Android via Java help you generate thumbnail images of the slides. To generate the thumbnail of any desired slide using Aspose.Slides for Android via Java:

  1. Create an instance of the Presentation class.
  2. Obtain the reference of any desired slide by using its ID or index.
  3. Get the thumbnail image of the referenced slide on a specified scale.
  4. Save the thumbnail image in any desired image format.
// Instantiate a Presentation class that represents the presentation file
Presentation pres = new Presentation("ThumbnailFromSlide.pptx");
try {
    // Access the first slide
    ISlide sld = pres.getSlides().get_Item(0);

    // Create a full scale image
    IImage slideImage = sld.getImage(1f, 1f);

    // Save the image to disk in JPEG format
    try {
          slideImage.save("Thumbnail_out.jpg", ImageFormat.Jpeg);
    } finally {
         if (slideImage != null) slideImage.dispose();
    }
} finally {
    pres.dispose();
}

Create Thumbnail with User Defined Dimensions

  1. Create an instance of the Presentation class.
  2. Obtain the reference of any desired slide by using its ID or index.
  3. Get the thumbnail image of the referenced slide on a specified scale.
  4. Save the thumbnail image in any desired image format.
// Instantiate a Presentation class that represents the presentation file
Presentation pres = new Presentation("ThumbnailWithUserDefinedDimensions.pptx");
try {
    // Access the first slide
    ISlide sld = pres.getSlides().get_Item(0);

    // User defined dimension
    int desiredX = 1200;
    int desiredY = 800;

    // Getting scaled value  of X and Y
    float ScaleX = (float)(1.0 / pres.getSlideSize().getSize().getWidth()) * desiredX;
    float ScaleY = (float)(1.0 / pres.getSlideSize().getSize().getHeight()) * desiredY;
    
    // Create a full scale image
    IImage slideImage = sld.getImage(ScaleX, ScaleY);

    // Save the image to disk in JPEG format
    try {
          slideImage.save("Thumbnail_out.jpg", ImageFormat.Jpeg);
    } finally {
         if (slideImage != null) slideImage.dispose();
    }
} finally {
    pres.dispose();
}

Create Thumbnail from Slide in Notes Slides View

To generate the thumbnail of any desired slide in Notes Slide View using Aspose.Slides for Android via Java:

  1. Create an instance of the Presentation class.
  2. Obtain the reference of any desired slide by using its ID or index.
  3. Get the thumbnail image of the referenced slide on a specified scale in Notes Slide view.
  4. Save the thumbnail image in any desired image format.

The code snippet below produces a thumbnail of the first slide of a presentation in Notes Slide View.

// Instantiate a Presentation class that represents the presentation file
Presentation pres = new Presentation("ThumbnailWithUserDefinedDimensions.pptx");
try {
    // Access the first slide
    ISlide sld = pres.getSlides().get_Item(0);

    // User defined dimension
    int desiredX = 1200;
    int desiredY = 800;

    // Getting scaled value  of X and Y
    float ScaleX = (float)(1.0 / pres.getSlideSize().getSize().getWidth()) * desiredX;
    float ScaleY = (float)(1.0 / pres.getSlideSize().getSize().getHeight()) * desiredY;

    RenderingOptions opts = new RenderingOptions();
    opts.getNotesCommentsLayouting().setNotesPosition(NotesPositions.BottomTruncated);
    
    // Create a full scale image
    IImage slideImage = sld.getImage(opts, ScaleX, ScaleY);

    // Save the image to disk in JPEG format
    try {
          slideImage.save("Thumbnail_out.jpg", ImageFormat.Jpeg);
    } finally {
         if (slideImage != null) slideImage.dispose();
    }
} finally {
    pres.dispose();
}