我正在寻找一个可以实现此目的的代码片段,最好是用 C# 甚至 Perl 编写。
我希望这不是一项艰巨的任务;)
下面将打开C:\presentation1.ppt
并将幻灯片另存为C:\Presentation1\slide1.jpg
etc.
如果您需要获取互操作程序集,可以在 Office 安装程序的“工具”下找到它,也可以从这里(Office 2003)。如果您有较新版本的 Office,您应该能够从那里找到其他版本的链接。
using Microsoft.Office.Core;
using PowerPoint = Microsoft.Office.Interop.PowerPoint;
namespace PPInterop
{
class Program
{
static void Main(string[] args)
{
var app = new PowerPoint.Application();
var pres = app.Presentations;
var file = pres.Open(@"C:\Presentation1.ppt", MsoTriState.msoTrue, MsoTriState.msoTrue, MsoTriState.msoFalse);
file.SaveCopyAs(@"C:\presentation1.jpg", Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsJPG, MsoTriState.msoTrue);
}
}
}
Edit:
司南的版本使用导出看起来是一个更好的选择,因为您可以指定输出分辨率。对于 C#,将上面的最后一行更改为:
file.Export(@"C:\presentation1.jpg", "JPG", 1024, 768);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)