Public API and Backwards Incompatible Changes in Aspose.Slides for .NET 14.9.0
Public API Changes
Inheritance from ICollection and Generic IEnumerable Interfaces Added to ISmartArtNodeCollection
The class Aspose.Slides.SmartArt.SmartArtNodeCollection (and the related interface Aspose.Slides.SmartArt.ISmartArtNodeCollection) inherit the generic interface IEnumerable
SmartArtLayoutType.Custom Enum Value Added
The Custom SmartArt layout type represents a diagram with a custom template. Custom diagrams can only be loaded from a presentation file and can’t be created via the ShapeCollection.AddSmartArt(x, y, width, height, SmartArtLayoutType.Custom) method.
SmartArtShape Class and ISmartArtShape Interface Added
The Aspose.Slides.SmartArt.SmartArtShape class (and its interface Aspose.Slides.SmartArt.ISmartArtShape) give access to individual shapes in a SmartArt diagram. SmartArtShape can be used to change FillFormat, LineFormat, adding Hyperlinks and other tasks.
Note: SmartArtShape does not support the IShape properties RawFrame, Frame, Rotation, X, Y, Width, Height and throws a System.NotSupportedException when attempting to access them.
Example of usage:
using (Presentation pres = new Presentation())
{
ISmartArt smart = pres.Slides[0].Shapes.AddSmartArt(10, 10, 400, 300, SmartArtLayoutType.BasicBlockList);
ISmartArtNode node = smart.AllNodes[0];
foreach (SmartArtShape shape in node.Shapes)
{
<span class="n">shape</span><span class="p">.</span><span class="n">FillFormat</span><span class="p">.</span><span class="n">FillType</span> <span class="p">=</span> <span class="n">FillType</span><span class="p">.</span><span class="n">Solid</span><span class="p">;</span>
<span class="n">shape</span><span class="p">.</span><span class="n">FillFormat</span><span class="p">.</span><span class="n">SolidFillColor</span><span class="p">.</span><span class="n">Color</span> <span class="p">=</span> <span class="n">Color</span><span class="p">.</span><span class="n">Red</span><span class="p">;</span>
}
pres.Save("out.pptx", Export.SaveFormat.Pptx);
}
SmartArtShapeCollection Class, ISmartArtShapeCollection Interface and ISmartArtNode.Shapes Property Added
The Aspose.Slides.SmartArt.SmartArtShapeCollection class (and its interface Aspose.Slides.SmartArt.ISmartArtShapeCollection) add access to individual shapes in a SmartArt diagram. The collection contains shapes associated with SmartArtNode. The SmartArtNode.Shapes property returns collections of all shapes associated with the node.
Note: depending on the SmartArtLayoutType one SmartArtShape can be shared between several nodes.
using (Presentation pres = new Presentation())
{
ISmartArt smart = pres.Slides[0].Shapes.AddSmartArt(10, 10, 400, 300, SmartArtLayoutType.BasicBlockList);
ISmartArtNode node = smart.AllNodes[0];
foreach (SmartArtShape shape in node.Shapes)
{
<span class="n">shape</span><span class="p">.</span><span class="n">FillFormat</span><span class="p">.</span><span class="n">FillType</span> <span class="p">=</span> <span class="n">FillType</span><span class="p">.</span><span class="n">Solid</span><span class="p">;</span>
<span class="n">shape</span><span class="p">.</span><span class="n">FillFormat</span><span class="p">.</span><span class="n">SolidFillColor</span><span class="p">.</span><span class="n">Color</span> <span class="p">=</span> <span class="n">Color</span><span class="p">.</span><span class="n">Red</span><span class="p">;</span>
}
pres.Save("out.pptx", Export.SaveFormat.Pptx);
}
Methods for Saving Slides with Page Numbers Keeping Added
The following methods have been added:
- void IPresentation.Save(string fname, int[] slides, SaveFormat format);
- void IPresentation.Save(string fname, int[] slides, SaveFormat format, ISaveOption options);
- void IPresentation.Save(Stream stream, int[] slides, SaveFormat format);
- void IPresentation.Save(Stream stream, int[] slides, SaveFormat format, ISaveOption options);
These methods allow developers to save specified presentation slides to PDF, XPS, TIFF, HTML formats. The ‘slides’ array is used to specify page numbers, starting from 1. Save(string fname, int[] slides, SaveFormat format);
Presentation presentation = new Presentation(presentationFileName);
int[] slides = new int[] { 2, 3, 5 }; //Array of slides positions
presentation.Save(outFileName, slides, SaveFormat.Pdf);
Methods for Replacing Images Added to PPImage, IPPImage
New methods added:
- IPPImage.ReplaceImage(byte[] newImageData)
- IPPImage.ReplaceImage(Image newImage)
- IPPImage.ReplaceImage(IPPImage newImage)
Presentation presentation = new Presentation(presentation.pptx);
//First method
byte[] data = File.ReadAllBytes(image0.jpeg);
IPPImage oldImage = presentation.Images[0];
oldImage.ReplaceImage(data);
//Second method
Image newImage = Image.FromFile(image1.png);
oldImage = presentation.Images[1];
oldImage.ReplaceImage(newImage);
//Third method
oldImage = presentation.Images[2];
oldImage.ReplaceImage(presentation.Images[3]);
presentation.Save(presentation_out.pptx, SaveFormat.Pptx);