Free Support Forum - aspose.com

Saving each build as new graphic

I was wondering if it is currenlty possible to save each build on a slide as a separate thumbnail? So if I have 4 slides and each slide as 4 builds, I will end up with 16 images. I looked through the API, but the only thing I would guess was that it might have to do with the Animation settings. Please provide a code sample if this is possible. If it is not currently supported, are there plans to add this in?

Thanks!

Dan Thayer

Dear Dan,

This feature is not supported yet. But you can use Slide.Getthumbnail(Size, Rectangle, IDrawingControl) to get the image of selected shapes of your choice.

For example the following code takes the image of those shapes whose alternative text has been set to "draw". I have also attached the source presentation and generated image of slide

*************************************************************************

internal class ListDrawingControl : IDrawingControl

{

Hashtable m_set;

public ListDrawingControl(ICollection shapesToDraw)

{

m_set = new Hashtable(shapesToDraw.Count);

IEnumerator enumerator = shapesToDraw.GetEnumerator();

while (enumerator.MoveNext())

{

m_set[enumerator.Current] = enumerator.Current;

}

}

#region IDrawingControl Members

public Aspose.Slides.DrawingControlDecision CheckObject(object objectToCheck, System.Collections.IList parents)

{

if (m_set.Contains(objectToCheck))

return DrawingControlDecision.Draw;

else

return DrawingControlDecision.IgnoreAskAboutChildren;

}

#endregion

}

static void GetThumbnailPartly()

{

Presentation pres = new Presentation(@"c:\srcShapes.ppt");

Slide sld = pres.GetSlideByPosition(1);

//Select all shapes whose alternative text is draw

List lstShapes = new List();

foreach (Shape shp in sld.Shapes)

{

if (shp.AlternativeText=="draw" )

lstShapes.Add(shp);

}

//Create object of ListDrawingControl and add all shapes

ListDrawingControl lstDrawingCntrl = new ListDrawingControl(lstShapes);

//Get the image of selected shapes

int imgWidth = pres.SlideSize.Width;

int imgHeight = pres.SlideSize.Height;

System.Drawing.Rectangle rectPane = new System.Drawing.Rectangle(0, 0, pres.SlideSize.Width, pres.SlideSize.Height);

Image img =sld.GetThumbnail(new Size(imgWidth, imgHeight),rectPane, lstDrawingCntrl);

img.Save(@"c:\outPartlyOutput.jpg");

}

Thanks for the reply. While the example you provided may be helpful for some people, it won't do us any good. In our situation we receive the PPTs from several different clients and can't expect them to "label" the builds with Alternative text.

Please let me know how long it will be until the Build functionality is added to Aspose.Slides. I imagine it would work similar to the following.

For Each slide In PPT
For Each build In Slide.builds
Save Thumbnail
Next
Next

Thanks for your hard work, and I look forward to your reply.

Dan Thayer

Dear Dan,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I will let you know the estimated time, before that; please attach some sample ppt having slides with builds.

Here is a very simple example of builds.

Dan Thayer

Dear Dan,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Do you mean thumbnail of slide before/after some animation executed? If yes, it won't be implemented because Aspose.Slides is not a player for presentations.

But GetThumbnail method can be called with collection of shapes which should be rendered. So you can create thumbnail with only one shape, with two shapes and etc. Order of animations is available so you can implement it.