C# PPT 转 图片/PDF
项目需要做的功能。 主要是PPT 转成 图片 图片在合成 一张大图。
VS2010 + win7 包换全部DLL 文件
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-06-29 15:44 WindowsFormsApplication2
文件 4500480 2018-06-29 09:44 WindowsFormsApplication21.ppt
文件 3308 2018-06-29 15:09 WindowsFormsApplication2Form1.Designer.cs
文件 5888 2018-06-29 15:40 WindowsFormsApplication2Form1.cs
文件 5817 2018-06-29 15:09 WindowsFormsApplication2Form1.resx
文件 505 2018-06-29 09:36 WindowsFormsApplication2Program.cs
目录 0 2018-06-29 15:44 WindowsFormsApplication2Properties
文件 1398 2018-06-29 09:36 WindowsFormsApplication2PropertiesAssemblyInfo.cs
文件 2876 2018-06-29 10:59 WindowsFormsApplication2PropertiesResources.Designer.cs
文件 5612 2018-06-29 09:36 WindowsFormsApplication2PropertiesResources.resx
文件 1107 2018-06-29 10:59 WindowsFormsApplication2PropertiesSettings.Designer.cs
文件 249 2018-06-29 09:36 WindowsFormsApplication2PropertiesSettings.settings
文件 4253 2018-06-29 15:40 WindowsFormsApplication2WindowsFormsApplication2.csproj
文件 143 2018-06-29 09:37 WindowsFormsApplication2WindowsFormsApplication2.csproj.user
文件 889 2018-06-29 09:37 WindowsFormsApplication2WindowsFormsApplication2.sln
文件 36352 2018-06-29 15:43 WindowsFormsApplication2WindowsFormsApplication2.suo
文件 144 2018-06-29 10:59 WindowsFormsApplication2app.config
目录 0 2018-06-29 15:44 WindowsFormsApplication2in
目录 0 2018-06-29 15:44 WindowsFormsApplication2inDebug
文件 4500480 2018-06-29 09:44 WindowsFormsApplication2inDebug1.ppt
目录 0 2018-06-29 15:44 WindowsFormsApplication2inDebug2
文件 14162965 2018-06-29 15:43 WindowsFormsApplication2inDebug2FinalImage_H.png
文件 150488 2018-06-29 15:42 WindowsFormsApplication2inDebug2幻灯片1.PNG
文件 1042602 2018-06-29 15:43 WindowsFormsApplication2inDebug2幻灯片10.PNG
文件 1482878 2018-06-29 15:43 WindowsFormsApplication2inDebug2幻灯片11.PNG
文件 105160 2018-06-29 15:43 WindowsFormsApplication2inDebug2幻灯片12.PNG
文件 366798 2018-06-29 15:43 WindowsFormsApplication2inDebug2幻灯片13.PNG
文件 43379 2018-06-29 15:43 WindowsFormsApplication2inDebug2幻灯片14.PNG
文件 79268 2018-06-29 15:43 WindowsFormsApplication2inDebug2幻灯片15.PNG
文件 92624 2018-06-29 15:43 WindowsFormsApplication2inDebug2幻灯片16.PNG
文件 697969 2018-06-29 15:43 WindowsFormsApplication2inDebug2幻灯片17.PNG
............此处省略61个文件信息
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 WindowsFormsApplication21.ppt
文件 3308 2018-06-29 15:09 WindowsFormsApplication2Form1.Designer.cs
文件 5888 2018-06-29 15:40 WindowsFormsApplication2Form1.cs
文件 5817 2018-06-29 15:09 WindowsFormsApplication2Form1.resx
文件 505 2018-06-29 09:36 WindowsFormsApplication2Program.cs
目录 0 2018-06-29 15:44 WindowsFormsApplication2Properties
文件 1398 2018-06-29 09:36 WindowsFormsApplication2PropertiesAssemblyInfo.cs
文件 2876 2018-06-29 10:59 WindowsFormsApplication2PropertiesResources.Designer.cs
文件 5612 2018-06-29 09:36 WindowsFormsApplication2PropertiesResources.resx
文件 1107 2018-06-29 10:59 WindowsFormsApplication2PropertiesSettings.Designer.cs
文件 249 2018-06-29 09:36 WindowsFormsApplication2PropertiesSettings.settings
文件 4253 2018-06-29 15:40 WindowsFormsApplication2WindowsFormsApplication2.csproj
文件 143 2018-06-29 09:37 WindowsFormsApplication2WindowsFormsApplication2.csproj.user
文件 889 2018-06-29 09:37 WindowsFormsApplication2WindowsFormsApplication2.sln
文件 36352 2018-06-29 15:43 WindowsFormsApplication2WindowsFormsApplication2.suo
文件 144 2018-06-29 10:59 WindowsFormsApplication2app.config
目录 0 2018-06-29 15:44 WindowsFormsApplication2in
目录 0 2018-06-29 15:44 WindowsFormsApplication2inDebug
文件 4500480 2018-06-29 09:44 WindowsFormsApplication2inDebug1.ppt
目录 0 2018-06-29 15:44 WindowsFormsApplication2inDebug2
文件 14162965 2018-06-29 15:43 WindowsFormsApplication2inDebug2FinalImage_H.png
文件 150488 2018-06-29 15:42 WindowsFormsApplication2inDebug2幻灯片1.PNG
文件 1042602 2018-06-29 15:43 WindowsFormsApplication2inDebug2幻灯片10.PNG
文件 1482878 2018-06-29 15:43 WindowsFormsApplication2inDebug2幻灯片11.PNG
文件 105160 2018-06-29 15:43 WindowsFormsApplication2inDebug2幻灯片12.PNG
文件 366798 2018-06-29 15:43 WindowsFormsApplication2inDebug2幻灯片13.PNG
文件 43379 2018-06-29 15:43 WindowsFormsApplication2inDebug2幻灯片14.PNG
文件 79268 2018-06-29 15:43 WindowsFormsApplication2inDebug2幻灯片15.PNG
文件 92624 2018-06-29 15:43 WindowsFormsApplication2inDebug2幻灯片16.PNG
文件 697969 2018-06-29 15:43 WindowsFormsApplication2inDebug2幻灯片17.PNG
............此处省略61个文件信息
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)