// Load PowerPoint presentation
Presentation presentation = new Presentation("D:\\work\\code\\demo\\WPFPPT\\test.ppt");
var slide = presentation.Slides[3];
// Save slide as SVG
var stream = new FileStream(@"D:\影像{0}.svg", FileMode.Create);
slide.WriteAsSvg(stream);
foreach (var item in presentation.Slides)
{
var shapes = item.Shapes;
foreach (var shape in shapes)
{
if(shape is IPictureFrame image)
{
var img = image.PictureFormat.Picture.Image;
var imageType = img.ContentType.Remove(0, img.ContentType.IndexOf("/") + 1);
ImageFormat format ;
switch (imageType)
{
case "jpeg":
format = System.Drawing.Imaging.ImageFormat.Jpeg;
break;
case "emf":
format = System.Drawing.Imaging.ImageFormat.Emf;
break;
case "bmp":
format = System.Drawing.Imaging.ImageFormat.Bmp;
break;
case "png":
format = System.Drawing.Imaging.ImageFormat.Png;
break;
case "wmf":
format = System.Drawing.Imaging.ImageFormat.Wmf;
break;
case "gif":
format = System.Drawing.Imaging.ImageFormat.Gif;
break;
}
img.SystemImage.Save(@$"D:\影像xx.{imageType}");
//img.ContentType
//img.BinaryData
//image.PictureFormat.Picture.Image.BinaryData.Save(stream, Aspose.Slides.Export.SaveFormat.Png);
//shape.Save(@"D:\影像{0}.png", Aspose.Slides.Export.SaveFormat.Png);
}
//presentation.Images.
//image.Picture.Save(stream, Aspose.Slides.Export.SaveFormat.Png);
//shape.Save(@"D:\影像{0}.png", Aspose.Slides.Export.SaveFormat.Png);
}
}
注入授權
//對應的授權碼
var v19_12 = "xxxxxx";
new Aspose.Slides.License().SetLicense(new MemoryStream(Convert.FromBase64String(v19_12)));