Hi. Can anyone give me some sample code to get me started on this?
I have a set of ppt files that have shapes, ellipses etc in them. I need to be able to read the ppt files using Aspose and then convert the shapes in png files embedded into html.
Any suggestions etc?
Thanks.
Dear aseem73
Thanks for considering Aspose.Slides.
You can get the images of indvidual shapes or selected shapes on the slide, below is the code example, how to achieve it.
C#
-------------------------------------------------------------------------------------------------------------------------------
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.IgnoreAskAboutChildren;
else
return DrawingControlDecision.Draw;
}
#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<Shape> lstShapes = new List<Shape>();
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");
}