从上面的代码可以发现,其实通过这个组件,我们还可以自由地设置我们想要的形状、文本、字体、颜色等等,用起来确实方便又快速。感兴趣的话可以试一下其他丰富的效果。
导出图片
现在,我们导出上述运行后文档的图片。
具体步骤:
同样添加如下命名空间:
using Spire.Presentation;
步骤1: 新建一个Presentation对象,并加载Presentation文件。
Presentation ppt = new Presentation();
ppt.LoadFromFile(@"C:UsersAdministratorDesktopresult.pptx");
步骤2:遍历PPT文档所有的图片,并保存为.png格式。
for (int i = 0; i < ppt.Images.Count; i++)
{
Image image = ppt.Images[i].Image;
image.Save(string.Format(@"....Images{0}.png", i));
}
效果图:

全部代码:
using System;
using System.Drawing;
using System.Windows.Forms;
using Spire.Presentation;
namespace ExtractImagesfromPPT
{
public partial class Form : Form
{
public Form()
{
InitializeComponent();
}
private void button_Click(object sender, EventArgs e)
{
Presentation ppt = new Presentation();
ppt.LoadFromFile(@"C:UsersAdministratorDesktopresult.pptx");
for (int i = ; i < ppt.Images.Count; i++)
{
Image image = ppt.Images[i].Image;
image.Save(string.Format(@"....Images{}.png", i));
}
}
}
}
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持ASPKU。
注:相关教程知识阅读请移步到c#教程频道。










