PowerPoint的优点在于对演示文档的操做上,而用PPT查看资料,反而会很麻烦。这时候,把PPT转换成PDF格式保存,再浏览,不失为一个好办法。在平常编程中和开发软件时,咱们也有这样的须要。本文旨在介绍使用免费的Spire.Presentation库,使用C#在.NET平台上实现PowerPoint (.ppt; .pptx)文件到PDF格式文件的转换。
有这方面须要的朋友,能够从
E-iceblue官方下载使用。下载完成后,请将bin文件夹的.DLL添加做为Visual Studio的引用。免费版本只能转3页。代码示例以下:
步骤1:建立新的presentation对象。
Presentation presentation = new Presentation()
presentation.LoadFromFile("Sample.pptx");
presentation.SaveToFile("ToPdf.pdf", FileFormat.PDF);
System.Diagnostics.Process.Start("ToPdf.pdf");
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Spire.Presentation;
namespace PPT转PDF
{
class Program
{
static void Main(string[] args)
{
Presentation presentation = new Presentation();
presentation.LoadFromFile("Sample.pptx");
presentation.SaveToFile("ToPdf.pdf", FileFormat.PDF);
System.Diagnostics.Process.Start("ToPdf.pdf");
}
}
}