处理文档时,常会将各种不同的文档转为需要的文档格式。在本文中,将介绍几种将PPT文档转为多种文档格式的方法,包括PPT转PDF、PPT转Image、PPT转PPTX、PPT转XPS、PPT转EMF。
PS:本方法中使用了免费版组件Spire.Presentation for .NET
1.PPT转PDF
class="c#" name="code">using System;
using Spire.Presentation;
namespace PPT转PDF
{
class Program
{
static void Main(string[] args)
{
//新建一个Presentation类对象,并加载需要转为目标对象的PPT文档
Presentation presentation = new Presentation();
presentation.LoadFromFile("Sample.pptx");
//保存PPT文档为PDF文档格式,并打开文档
presentation.SaveToFile("ToPdf.pdf", FileFormat.PDF);
System.Diagnostics.Process.Start("ToPdf.pdf");
}
}
}
?
2.同理,也可通过此方法将PPT转成Image,加载PPT文档后,写入如下代码段
// 保存幻灯片为Image
Image image = presentation.Slides[i].SaveAsImage();
String fileName = String.Format("result-img-{0}.png", i);
image.Save(“ToImage”, System.Drawing.Imaging.ImageFormat.Png);
System.Diagnostics.Process.Start(“ToImage”);
?
3.PPT转PPTX
//保存PPT为PPTX格式
presentation.SaveToFile("ToPPTX.pptx", FileFormat.Pptx2010);
System.Diagnostics.Process.Start("ToPPTX.pptx");
?4.PPT转XPS
//保存文件为XPS
ppt.SaveToFile("sample.xps", FileFormat.XPS);
?5.PPT转EMF
//保存PPT为EMF格式
presentation.Slides[2].SaveAsEMF("result.emf");
?
(本文转自http://www.cnblogs.com/Yesi/p/5388152.html)