• 大小: 32.97MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-07-05
  • 语言: C#
  • 标签: PPT转PDF  

资源简介

项目需要做的功能。 主要是PPT 转成 图片 图片在合成 一张大图。 VS2010 + win7 包换全部DLL 文件

资源截图

代码片段和文件信息

using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using Microsoft.Office.Core;
using PowerPoint = Microsoft.Office.Interop.PowerPoint;


namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        PowerPoint.PpSaveAsFileType ppType = Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsPNG;

        private void button1_Click(object sender EventArgs e)
        {
            DirectoryInfo dir = new DirectoryInfo(this.textBox2.Text.Trim());
            FileSystemInfo[] fileinfo = dir.GetFileSystemInfos();  //返回目录中所有文件和子目录
            foreach (FileSystemInfo i in fileinfo)
            {
                if (i is DirectoryInfo)            //判断是否文件夹
                {
                    DirectoryInfo subdir = new DirectoryInfo(i.FullName);
                    subdir.Delete(true);          //删除子目录和文件
                }
                else
                {
                    File.Delete(i.FullName);      //删除指定文件
                }
            }

            Convert(this.textBox1.Text.Trim() this.textBox2.Text.Trim() ppType);
            string folderPath = this.textBox2.Text.Trim();
            var images = new DirectoryInfo(folderPath).GetFiles(“*.Png“ SearchOption.TopDirectoryOnly);
            CombineImages(images this.textBox2.Text.Trim() + “\\FinalImage_H.png“);
            GC.Collect();
            GC.WaitForPendingFinalizers();
        }

        /// 
        /// ppt转换图片
        /// 

        /// 
        /// 
        /// 可以切换不同类型
        /// 
        private bool Convert(string sourcePath string targetPath Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType targetFileType)
        {
            bool result;
            object missing = Type.Missing;
            PowerPoint.ApplicationClass application = null;
            Microsoft.Office.Interop.PowerPoint.Presentation persentation = null;
            try
            {
                application = new PowerPoint.ApplicationClass();
                persentation = application.Presentations.Open(sourcePath MsoTriState.msoFalse MsoTriState.msoFalse MsoTriState.msoTrue);
                persentation.SaveAs(targetPath targetFileType Microsoft.Office.Core.MsoTriState.msoFalse);
                result = true;
            }
            catch
            {
                result = false;
            }
            finally
            {
                if (persentation != null)
                {
                    persentation.Close();
                    persentation = null;
                }
                if (application != null)
                {
       

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-06-29 15:44  WindowsFormsApplication2\
     文件     4500480  2018-06-29 09:44  WindowsFormsApplication2\1.ppt
     文件        3308  2018-06-29 15:09  WindowsFormsApplication2\Form1.Designer.cs
     文件        5888  2018-06-29 15:40  WindowsFormsApplication2\Form1.cs
     文件        5817  2018-06-29 15:09  WindowsFormsApplication2\Form1.resx
     文件         505  2018-06-29 09:36  WindowsFormsApplication2\Program.cs
     目录           0  2018-06-29 15:44  WindowsFormsApplication2\Properties\
     文件        1398  2018-06-29 09:36  WindowsFormsApplication2\Properties\AssemblyInfo.cs
     文件        2876  2018-06-29 10:59  WindowsFormsApplication2\Properties\Resources.Designer.cs
     文件        5612  2018-06-29 09:36  WindowsFormsApplication2\Properties\Resources.resx
     文件        1107  2018-06-29 10:59  WindowsFormsApplication2\Properties\Settings.Designer.cs
     文件         249  2018-06-29 09:36  WindowsFormsApplication2\Properties\Settings.settings
     文件        4253  2018-06-29 15:40  WindowsFormsApplication2\WindowsFormsApplication2.csproj
     文件         143  2018-06-29 09:37  WindowsFormsApplication2\WindowsFormsApplication2.csproj.user
     文件         889  2018-06-29 09:37  WindowsFormsApplication2\WindowsFormsApplication2.sln
     文件       36352  2018-06-29 15:43  WindowsFormsApplication2\WindowsFormsApplication2.suo
     文件         144  2018-06-29 10:59  WindowsFormsApplication2\app.config
     目录           0  2018-06-29 15:44  WindowsFormsApplication2\bin\
     目录           0  2018-06-29 15:44  WindowsFormsApplication2\bin\Debug\
     文件     4500480  2018-06-29 09:44  WindowsFormsApplication2\bin\Debug\1.ppt
     目录           0  2018-06-29 15:44  WindowsFormsApplication2\bin\Debug\2\
     文件    14162965  2018-06-29 15:43  WindowsFormsApplication2\bin\Debug\2\FinalImage_H.png
     文件      150488  2018-06-29 15:42  WindowsFormsApplication2\bin\Debug\2\幻灯片1.PNG
     文件     1042602  2018-06-29 15:43  WindowsFormsApplication2\bin\Debug\2\幻灯片10.PNG
     文件     1482878  2018-06-29 15:43  WindowsFormsApplication2\bin\Debug\2\幻灯片11.PNG
     文件      105160  2018-06-29 15:43  WindowsFormsApplication2\bin\Debug\2\幻灯片12.PNG
     文件      366798  2018-06-29 15:43  WindowsFormsApplication2\bin\Debug\2\幻灯片13.PNG
     文件       43379  2018-06-29 15:43  WindowsFormsApplication2\bin\Debug\2\幻灯片14.PNG
     文件       79268  2018-06-29 15:43  WindowsFormsApplication2\bin\Debug\2\幻灯片15.PNG
     文件       92624  2018-06-29 15:43  WindowsFormsApplication2\bin\Debug\2\幻灯片16.PNG
     文件      697969  2018-06-29 15:43  WindowsFormsApplication2\bin\Debug\2\幻灯片17.PNG
............此处省略61个文件信息

评论

共有 条评论

相关资源