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()
步骤2:加载PPT文档。
presentation.LoadFromFile(“Sample.pptx”);
步骤3:将PPT文档转换为PDF文档。
presentation.SaveToFile(“ToPdf.pdf”, FileFormat.PDF);
步骤4:启动文档查看效果。
System(“ToPdf.pdf”);
原PPT文档截图:
转换成PDF后效果截图:
全部代码:
using System;using Systemusing 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(“ToPdf.pdf”);}}}
感谢阅读,有任何建议或意见,请不吝指出.
没有预兆目的地在哪,前进的脚步不能停下,