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");
}
}
}