API pública y cambios incompatibles hacia atrás en Aspose.Slides para .NET 14.9.0
Cambios en la API pública
Herencia de las interfaces ICollection y IEnumerable genéricas añadida a ISmartArtNodeCollection
La clase Aspose.Slides.SmartArt.SmartArtNodeCollection (y la interfaz relacionada Aspose.Slides.SmartArt.ISmartArtNodeCollection) heredan la interfaz genérica IEnumerable
Valor de enumeración SmartArtLayoutType.Custom añadido
El tipo de diseño SmartArt Custom representa un diagrama con una plantilla personalizada. Los diagramas personalizados solo pueden cargarse desde un archivo de presentación y no pueden crearse mediante el método ShapeCollection.AddSmartArt(x, y, width, height, SmartArtLayoutType.Custom).
Clase SmartArtShape e interfaz ISmartArtShape añadidas
La clase Aspose.Slides.SmartArt.SmartArtShape (y su interfaz Aspose.Slides.SmartArt.ISmartArtShape) brinda acceso a formas individuales en un diagrama SmartArt. SmartArtShape puede usarse para cambiar FillFormat, LineFormat, añadir Hipervínculos y otras tareas.
Nota: SmartArtShape no admite las propiedades IShape RawFrame, Frame, Rotation, X, Y, Width, Height y lanza una System.NotSupportedException al intentar acceder a ellas.
Ejemplo de uso:
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);
}
Clase SmartArtShapeCollection, interfaz ISmartArtShapeCollection y propiedad ISmartArtNode.Shapes añadidas
La clase Aspose.Slides.SmartArt.SmartArtShapeCollection (y su interfaz Aspose.Slides.SmartArt.ISmartArtShapeCollection) brinda acceso a formas individuales en un diagrama SmartArt. La colección contiene las formas asociadas a SmartArtNode. La propiedad SmartArtNode.Shapes devuelve colecciones de todas las formas asociadas al nodo.
Nota: dependiendo del SmartArtLayoutType, una SmartArtShape puede ser compartida entre varios nodos.
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);
}
Métodos para guardar diapositivas con números de página añadidos
Se han añadido los siguientes métodos:
- 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);
Estos métodos permiten a los desarrolladores guardar diapositivas específicas de la presentación en formatos PDF, XPS, TIFF, HTML. La matriz ‘slides’ se usa para especificar los números de página, comenzando desde 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);
Métodos para reemplazar imágenes añadidos a PPImage, IPPImage
Nuevos métodos añadidos:
- IPPImage.ReplaceImage(byte[] newImageData)
- IPPImage.ReplaceImage(Image newImage)
- IPPImage.ReplaceImage(IPPImage newImage)
Presentation presentation = new Presentation(presentation.pptx);
//Primer método
byte[] data = File.ReadAllBytes(image0.jpeg);
IPPImage oldImage = presentation.Images[0];
oldImage.ReplaceImage(data);
//Segundo método
Image newImage = Image.FromFile(image1.png);
oldImage = presentation.Images[1];
oldImage.ReplaceImage(newImage);
//Tercer método
oldImage = presentation.Images[2];
oldImage.ReplaceImage(presentation.Images[3]);
presentation.Save(presentation_out.pptx, SaveFormat.Pptx);