.net mvc 上传PPT文件转化为图片解决方案
来源:互联网 发布:2.5d弧面玻璃淘宝有吗 编辑:程序博客网 时间:2024/05/17 03:29
后台代码:
using System;
using System.Collections.Generic;using System.Linq;
using System.Web;
using System.Web.Mvc;
using Microsoft.Office.Core;
using Microsoft.Office.Interop.PowerPoint;
using System.Threading;
using System.IO;
namespace ppt2imageDemo.Controllers
{
public class HomeController : Controller
{
//
// GET: /Home/
public ActionResult Index()
{
return View();
}
public JsonResult PushFilesAjax() {
var file = Request.Files[0];
var path = AppDomain.CurrentDomain.BaseDirectory + "imagesfromppt/" + file.FileName;
var savepath = AppDomain.CurrentDomain.BaseDirectory + "ppt/";
if(!System.IO.Directory.Exists(path)){
System.IO.Directory.CreateDirectory(path);
}
if (!System.IO.Directory.Exists(savepath))
{
System.IO.Directory.CreateDirectory(savepath);
}
var filepath = Path.Combine(savepath, file.FileName);
file.SaveAs(filepath);
Microsoft.Office.Interop.PowerPoint.Application application = null;
Presentation persentation = null;
try
{
application = new Microsoft.Office.Interop.PowerPoint.Application();
persentation = application.Presentations.Open(filepath);
//persentation.Slides[1].Export(path + "\\page" + 1 + ".jpg", "JPG", 800, 600);
for (var k = 1; k <= persentation.Slides.Count;k++ )
{
persentation.Slides[k].Export(path + "\\page" + k + ".jpg", "JPG", 800, 600);
}
}
catch(Exception e) {
Console.WriteLine(e.Message);
}
finally
{
if (persentation != null)
{
persentation.Close();
persentation = null;
}
if (application != null)
{
application.Quit();
application = null;
}
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
GC.WaitForPendingFinalizers();
}
return Json(new { success=true});
}
}
}
阅读全文
0 0
- .net mvc 上传PPT文件转化为图片解决方案
- .NET MVC 图片上传
- 在.net MVC中异步上传图片或者文件
- .net mvc web api上传图片/文件并重命名
- ASP.NET MVC图片文件上传与下载
- ASP.NET MVC 图片上传
- 图片转化为base64及上传
- MVC中上传图片文件
- asp.net 上传判断文件是否为图片
- asp.net FileUpload 判断上传文件是否为图片
- ASP.NET MVC 上传文件
- ASP.NET MVC - 文件上传
- asp.net MVC上传文件
- asp.net mvc文件上传
- ASP.NET MVC上传文件
- asp.net mvc文件上传
- asp.net mvc文件上传
- ASP.NET MVC上传文件
- 类:实验2家中的电视
- COCOS2D-X Battle 独立游戏 (一) 第一版文案
- phpexcel 找不到xmlwriter问题的解决
- 万里长征第一步
- [arc058d]Iroha and a Grid
- .net mvc 上传PPT文件转化为图片解决方案
- Vue 2.5 发布了:15篇前端热文回看
- DL para tuning tricks
- MVP模式介绍以及和mvc对比
- oracle PL/SQL基础知识2
- [实战笔记]Android文本编辑的一些实用技巧
- HDU 4280Island Transport(裸最大流)
- day09-工作--没有学习
- HttpClient使用详解总结大全②