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


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

            }
        }
    }
    复制代码
  • 相关阅读:
    bigint int smallint tinyint 我是个马大哈
    [转载]Jquery主要控件的取值、赋值,包括textbox,butt
    几个时间转化格式
    Linq 事务问题
    手机网页开发
    PM2.5口罩网上热销 防护作用有限“噱头”多
    按F5键刷新造成的数据重复提交
    Ajax中遇到的一点细节问题
    WCF(二)将WCF发布到WindowsService
    WCF(一)
  • 原文地址:https://www.cnblogs.com/soundcode/p/11779994.html
Copyright © 2020-2023  润新知