首页 > 编程语言 >Aspose.Slides.NET 19.2 解析ppt内容保存svg 保存ppt内部图片

Aspose.Slides.NET 19.2 解析ppt内容保存svg 保存ppt内部图片

时间:2024-08-03 17:20:55浏览次数:23  
标签:19.2 format 保存 Slides ImageFormat ppt var Aspose Imaging


// 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)));

标签:19.2,format,保存,Slides,ImageFormat,ppt,var,Aspose,Imaging
From: https://www.cnblogs.com/ives/p/18340800

相关文章