資源簡介
先將office文件轉換為pdf,然后再將pdf轉換為swf文件

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Linq;
using?System.Web;
using?System.Web.UI;
using?System.Web.UI.WebControls;
using?System.IO;
using?System.Diagnostics;
using?System.Text;
using?System.Threading;
namespace?WebApplication1
{
????public?partial?class?_Default?:?System.Web.UI.Page
????{
????????protected?void?Page_Load(object?sender?EventArgs?e)
????????{
????????}
????????protected?void?Button1_Click(object?sender?EventArgs?e)
????????{?
????????????string?fs_filename?=?Server.MapPath(“UploadedFiles/“)?+?FileUpload1.FileName;
????????????FileUpload1.SaveAs(fs_filename);
????????????string?fileName?=?FileUpload1.FileName.Substring(0?FileUpload1.FileName.LastIndexOf(‘.‘));
????????????string?fs_convertedfilename?=?Server.MapPath(“ConvertedFiles/“)?+?fileName?+?“.pdf“;
?????????
????????????if?(!File.Exists(fs_convertedfilename))
????????????{
????????????????OfficeToPDF?pdf?=?new?OfficeToPDF();
????????????????string?sub?=?fs_filename.Substring(fs_filename.LastIndexOf(‘.‘)?+?1);
????????????????switch?(sub)
????????????????{
????????????????????case?“docx“:
????????????????????case?“doc“:
????????????????????case?“dotx“:
????????????????????case?“dot“:
????????????????????????pdf.DOCConvertToPDF(fs_filename?fs_convertedfilename);
????????????????????????break;
????????????????????case?“xls“:
????????????????????case?“xlsx“:
????????????????????case?“xlsm“:
????????????????????case?“xlsb“:
????????????????????????pdf.XLSConvertToPDF(fs_filename?fs_convertedfilename);
????????????????????????break;
????????????????????case?“pdf“:
????????????????????????File.Move(fs_filename?fs_convertedfilename);
????????????????????????break;
????????????????????case?“txt“:
????????????????????????break;
????????????????}
????????????}
?????????????
????????????Thread.Sleep(3000);
????????????ConvertToSwf(fs_convertedfilename?Server.MapPath(“ConvertedFiles/“)?+?fileName?+?“.swf“);
????????????//pdf.XLSConvertToPDF(fs_filename?fs_convertedfilename);
????????}
????????///?
????????///?將PDF轉換為SWF文件
????????///?
????????///?PDF文件路徑
????????///?SWF文件路徑
????????///?
????????public??void?ConvertToSwf(string?pdfPath?string?swfPath)
????????{
????????????try
????????????{
????????????????string?exe?=?@“C:\Program?Files\SWFTools\pdf2swf.exe“;
????????????????if?(!File.Exists(exe))
????????????????{
????????????????????throw?new?ApplicationException(“Can?not?find:?“?+?exe);
????????????????}
????????????????StringBuilder?sb?=?new?StringBuilder();
????????????????sb.Append(“?-o?\““?+?swfPath?+?“\““);//output
????????????????sb.Append(“?-z“);
????????????????sb.Append(“?-s?flashversion=9“);//flash?version
????????????????sb.Append(“?-s?disablelinks“);//禁止PDF里面的鏈接
????????????????//sb.Append(“?-p?“?+?“1“?+?“-“?+?page);//page?range
?????????????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????935??2014-03-21?14:31??MyTest002\MyTest002.sln
????..A..H.?????20480??2014-03-26?14:42??MyTest002\MyTest002.suo
?????文件??????53248??2014-03-21?13:52??MyTest002\WebApplication1\bin\Interop.Print2Flash3.dll
?????文件???????8704??2014-03-24?13:52??MyTest002\WebApplication1\bin\WebApplication1.dll
?????文件??????17920??2014-03-24?13:52??MyTest002\WebApplication1\bin\WebApplication1.pdb
?????文件????????590??2014-03-26?14:41??MyTest002\WebApplication1\Default.aspx
?????文件???????3751??2014-03-26?14:41??MyTest002\WebApplication1\Default.aspx.cs
?????文件???????1545??2014-03-26?14:41??MyTest002\WebApplication1\Default.aspx.designer.cs
?????文件????????503??2014-03-24?13:52??MyTest002\WebApplication1\obj\Debug\WebApplication1.csproj.FileListAbsolute.txt
?????文件????????731??2014-03-24?13:52??MyTest002\WebApplication1\obj\Debug\WebApplication1.csproj.ResolveComReference.cache
?????文件???????8704??2014-03-24?13:52??MyTest002\WebApplication1\obj\Debug\WebApplication1.dll
?????文件??????17920??2014-03-24?13:52??MyTest002\WebApplication1\obj\Debug\WebApplication1.pdb
?????文件???????7834??2014-03-26?14:42??MyTest002\WebApplication1\PDF.cs
?????文件???????1329??2014-03-21?14:30??MyTest002\WebApplication1\Properties\AssemblyInfo.cs
?????文件???????7376??2014-03-26?10:46??MyTest002\WebApplication1\Web.config
?????文件???????5797??2014-03-21?17:36??MyTest002\WebApplication1\WebApplication1.csproj
?????文件???????1299??2014-03-21?17:36??MyTest002\WebApplication1\WebApplication1.csproj.user
?????文件????????483??2014-03-24?13:53??MyTest002\WebApplication1\WebApplication1.Publish.xm
?????文件????????750??2014-03-26?14:39??MyTest002\異常解決辦法.txt
?????目錄??????????0??2014-03-21?14:30??MyTest002\WebApplication1\obj\Debug\TempPE
?????目錄??????????0??2014-03-24?13:52??MyTest002\WebApplication1\obj\Debug
?????目錄??????????0??2014-03-21?14:30??MyTest002\WebApplication1\App_Data
?????目錄??????????0??2014-03-24?13:52??MyTest002\WebApplication1\bin
?????目錄??????????0??2014-03-24?13:52??MyTest002\WebApplication1\ConvertedFiles
?????目錄??????????0??2014-03-21?14:30??MyTest002\WebApplication1\obj
?????目錄??????????0??2014-03-21?14:30??MyTest002\WebApplication1\Properties
?????目錄??????????0??2014-03-26?14:42??MyTest002\WebApplication1\UploadedFiles
?????目錄??????????0??2014-03-26?14:42??MyTest002\WebApplication1
?????目錄??????????0??2014-03-26?14:39??MyTest002
-----------?---------??----------?-----??----
............此處省略2個文件信息
評論
共有 條評論