zhuan https://www.cnblogs.com/ywtk/archive/2013/09/02/3295973.html
要实现PPT转图片,首先需要引用两个DLL。
我这里用的这个这个版本
Microsoft.Office.Interop.PowerPoint 12.0
Microsoft Office 12.0 object Library
如下图:
代码如下:
private void pptToImg(string pptPath, string imgPath)
{
var app = new Microsoft.Office.Interop.PowerPoint.Application();
var ppt = app.Presentations.Open(pptPath, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse);
var index = 0;
var fileName = Path.GetFileNameWithoutExtension(pptPath);
foreach (Microsoft.Office.Interop.PowerPoint.Slide slid in ppt.Slides)
{
++index;
//设置图片大小
slid.Export(imgPath+string.Format("page{0}.png",index.ToString()), "png", 1024, 768);
//根据屏幕尺寸。设置图片大小
//slid.Export(imgPath+string.Format("page{0}.jpg",index.ToString()), "jpg", Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
}
//释放资源
ppt.Close();
app.Quit();
GC.Collect();
}
原文:https://www.cnblogs.com/lhlong/p/11609384.html