C# 将PowerPoint文件转换成PDF文件

mac2022-06-30  65

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.Diagnostics.Process.Start( " ToPdf.pdf ");

 

原PPT文档截图:

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

 

转载于:https://www.cnblogs.com/Yesi/p/4835702.html

相关资源:JAVA上百实例源码以及开源项目
最新回复(0)