以下是用C#编写的PPT转PDF程序示例:

using Microsoft.Office.Interop.PowerPoint;
using Microsoft.Office.Interop.Word;
using System;
using System.IO;

namespace PPTtoPDF
{
    class Program
    {
        static void Main(string[] args)
        {
            string pptPath = @"C:\path\to\ppt\file.pptx";
            string pdfPath = @"C:\path\to\pdf\file.pdf";

            // Create a new instance of PowerPoint application
            Application pptApplication = new Application();

            // Open the PowerPoint presentation
            Presentation pptPresentation = pptApplication.Presentations.Open(pptPath, WithWindow: MsoTriState.msoFalse);

            // Save the presentation as PDF
            pptPresentation.ExportAsFixedFormat(pdfPath, PpFixedFormatType.ppFixedFormatTypePDF);

            // Close the presentation and quit PowerPoint application
            pptPresentation.Close();
            pptApplication.Quit();

            Console.WriteLine("PPT to PDF conversion completed successfully.");
        }
    }
}

该程序使用Microsoft Office Interop库,因此需要在项目中添加对Microsoft PowerPoint和Microsoft Word的引用。运行程序后,将在指定的输出路径中生成一个PDF文件。

用C#写一个ppt转pdf的程序

原文地址: https://www.cveoy.top/t/topic/b2ig 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录