zoukankan      html  css  js  c++  java
  • 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");

            }
        }
    }
  • 相关阅读:
    mysql中给查询结果添加序号
    Mysql如何取当日的数据
    nginx 出现413 Request Entity Too Large问题的解决方法
    Mac 安装Jupyter Notebook
    Python-用xlrd模块读取excel,数字都是浮点型,日期格式是数字的解决办法
    sql-exists、not exists的用法
    sql语句replace函数的使用
    Python-日期格式化
    Python-自动用0补取长度
    Flask-实现下载功能
  • 原文地址:https://www.cnblogs.com/Yesi/p/4835702.html
Copyright © 2011-2022 走看看