office文件在线预览

合集下载
相关主题
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

1、这个文档在线预览支持IE、谷歌、火狐、等主流浏览器。

2、直接是通过后台代码做的转换。所以在主流的浏览器平台上几乎没有兼容性问题

3、引用封装好的程序集,转换起来更加方便、快捷

4、完全抛弃了微软的office办公组件

5、有下载券的同学不要吝啬呀(我缺/(ㄒoㄒ)/~~)

6、没下载的券的留言,我发给你

using System;

using System.Collections.Generic;

using System.Diagnostics;

using System.IO;

using System.Linq;

using System.Web;

using Aspose.Cells;

using Aspose.Pdf.Devices;

using Aspose.Slides;

using Aspose.Words;

using Pdf = Aspose.Pdf;

namespace Spacebuilder.File

{

public class DocViewService

{

///

/// 获取swf的转换地址

///

///

///

public string GetSwfUrl(string filePath)

{

try

{

string suffixName = filePath.Substring(stIndexOf('.') + 1);

string fileName = GetFileName(filePath);

string pdfurl = HttpContext.Current.Server.MapPath("~/Uploads/pdfs/");

pdfurl = string.Format("{0}{1}.pdf", pdfurl, fileName);

string swfPath = "error.swf";

if (suffixName == "swf")

{

return filePath;

}

if (ExistFile(pdfurl))

{

return Pdf2Swf(pdfurl);

}

switch (suffixName)

{

case "rar":

case "zip":

break;

case "mp4":

swfPath = "mp4";

break;

case "xls":

case "xlsx":

Workbook xls = new Workbook(filePath);

xls.Save(pdfurl, Aspose.Cells.SaveFormat.Pdf);

break;

case "txt":

case "docx":

case "doc":

Document doc = new Document(filePath);

doc.Save(pdfurl);

break;

case "ppt":

case "pptx":

Presentation ppt = new Presentation(filePath);

ppt.Save(pdfurl, Aspose.Slides.Export.SaveFormat.Pdf);

break;

case "pdf":

pdfurl = filePath;

break;

}

swfPath = Pdf2Swf(pdfurl);

return swfPath;

}

catch (Exception)

{

return "error.swf";

}

}

///

/// 获取pdf转换的swf地址

///

///

///

public string GetHtmlUrl(string filePath)

{

try

{

string suffixName = GetsuffixName(filePath);

string fileName = GetFileName(filePath);

string pdfurl = HttpContext.Current.Server.MapPath("~/Uploads/pdfs/");

pdfurl = string.Format("{0}{1}.pdf", pdfurl, fileName);

string htmlPath = "/Pdf2Html/error.html";

if (suffixName == "swf")

{

return filePath;

}

if (ExistFile(pdfurl))

{

return Pdf2Html(pdfurl);

}

switch (suffixName)

{

case "rar":

case "zip":

break;

case "mp4":

htmlPath = "mp4";

break;

case "xls":

case "xlsx":

Workbook xls = new Workbook(filePath);

xls.Save(pdfurl, Aspose.Cells.SaveFormat.Pdf);

break;

case "txt":

case "docx":

case "doc":

Document doc = new Document(filePath);

doc.Save(pdfurl);

break;

case "ppt":

case "pptx":

Presentation ppt = new Presentation(filePath);

ppt.Save(pdfurl, Aspose.Slides.Export.SaveFormat.Pdf);

break;

case "pdf":

pdfurl = filePath;

break;

相关文档
最新文档