PPT处理控件Aspose.Slides功能演示:在 C# 中将 PPTX/PPT 转换为 PNG 图像

  • 将 PowerPoint PPTX 或 PPT 转换为 PNG

为了将 PPTX 或 PPT 演示文稿转换为 PNG,我们将使用Aspose.Slides for .NET,它是一个功能丰富的 API,可让您使用 C# 创建、修改和转换 PowerPoint 和 OpenOffice 演示文稿。

>>你可以点击这里下载Aspose.Slides 最新版测试体验。

在 C# 中将 PowerPoint PPTX 或 PPT 转换为 PNG

以下是使用 C# 将 PowerPoint PPTX 中的幻灯片转换为 PNG 图像的步骤。

  • 首先,创建Presentation 类的一个实例 来加载演示文稿。
  • 循环每一个 I幻灯片式 的 Presentation.Slides 集合。
  • 定义生成的 PNG 图像的尺寸。
  • 使用ISlide.GetThumbnail(float ScaleX, float ScaleY) 方法生成每张幻灯片的图像,并将图像 的引用放入 Bitmap 对象。
  • 最后,使用Bitmap.Save(String, System.Drawing.Imaging.ImageFormat.Png) 方法将图像保存为 PNG 。

以下代码示例展示了如何将 PowerPoint PPTX 转换为 PNG。

// Load PowerPoint presentationusing (Presentation pres = new Presentation("presentation.pptx")){    // User defined dimension    int desiredX = 1200;    int desiredY = 800;    // Getting scaled value of X and Y    float ScaleX = (float)(1.0 / pres.SlideSize.Size.Width) * desiredX;    float ScaleY = (float)(1.0 / pres.SlideSize.Size.Height) * desiredY;    foreach (ISlide sld in pres.Slides)    {        // Create a full scale image        Bitmap bmp = sld.GetThumbnail(ScaleX, ScaleY);        // Save the image to disk in PNG format        bmp.Save(String.Format("slide_{0}.png", sld.SlideNumber), System.Drawing.Imaging.ImageFormat.Png);    }}

如果你想试用Aspose的全部完整功能,可联系在线客服获取30天临时授权体验。


还想要更多吗可以点击阅读【Aspose最新资源在线文库】查找需要的教程资源。如果您有任何疑问或需求,请随时加入Aspose技术交流群(),我们很高兴为您提供查询和咨询
标签:

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2021年8月3日
下一篇 2021年8月3日

相关推荐

发表回复

登录后才能评论