office转换swf

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

在线打开office文件大致步骤

一:上传服务器,在上传过程中,会根据类型转换,先同意转换为PDF,在转换为swf,二:用flash在线查看

先给出转换的源代码,需要引用4个dll。

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using Microsoft.Office.Interop.Word;

using System.Diagnostics;

using log4net;

using Microsoft.Office.Core;

///

///转换成swf文件不需要引入dll文件,主要是调用pdf2swf.exe

///

[assembly: log4net.Config.XmlConfigurator(Watch = true)]

public partial class ToSwf_toSwf : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

}

///

///点击上传

///

///

///

///

///转换成 SWF 文件

///

///命令

///命令参数

private static void ExcutedCmd(string cmd, string args)

{

using (Process p = new Process())

{

ProcessStartInfo psi = new ProcessStartInfo(cmd, args.Replace("\"", "")); p.StartInfo = psi;

p.Start();

p.WaitForExit();

}

}

// ///

// /// 点击查看

// ///

// ///

// ///

// protected void Btn_Viewer_Click(object sender, EventArgs e)

// {

// string url = "../show.aspx?id=" +

HttpUtility.HtmlEncode(ListBox1.SelectedValue);

// string script = @"

// ";

// Page.ClientScript.RegisterStartupScript(this.GetType(), "", script);

// }

///

///转换word为pdf

///

///doc文件路径

///pdf保存路径

private void ConvertWordPDF1(object filename)

{

// 添加COM引用 Microsoft Word 11.0 Object Library

string tmp_FilePath = filename.ToString();

// 先建立 Word 實體

ApplicationClass wordApplication = new ApplicationClass();

Document wordDocument = null;

// 宣告相對應等變數

object paramSourceDocPath = tmp_FilePath;

object paramMissing = Type.Missing;

// 把路徑檔名做處理...

Int32 intLastDot = tmp_stIndexOf(".");

//*********Temp Programming****************************************

tmp_FilePath = tmp_FilePath.Substring(0, intLastDot);

string paramExportFilePath = null;

WdExportFormat paramExportFormat = WdExportFormat.wdExportFormatPDF;

// 判別 user 欲轉換的格式 ( PDF 或 XPS)

//if (comboBox1.SelectedIndex == 0)

//{

paramExportFilePath = tmp_FilePath + ".pdf";

paramExportFormat = WdExportFormat.wdExportFormatPDF;

//}

//else if (comboBox1.SelectedIndex == 1)

//{

// paramExportFilePath = tmp_FilePath + ".xps";

// paramExportFormat = WdExportFormat.wdExportFormatXPS;

//}

// 宣告其他必要的使用變數

bool paramOpenAfterExport = false;

WdExportOptimizeFor paramExportOptimizeFor =

WdExportOptimizeFor.wdExportOptimizeForPrint;

WdExportRange paramExportRange = WdExportRange.wdExportAllDocument;

int paramStartPage = 0;

int paramEndPage = 0;

WdExportItem paramExportItem = WdExportItem.wdExportDocumentContent;

bool paramIncludeDocProps = true;

bool paramKeepIRM = true;

WdExportCreateBookmarks paramCreateBookmarks =

WdExportCreateBookmarks.wdExportCreateWordBookmarks;

bool paramDocStructureTags = true;

bool paramBitmapMissingFonts = true;

bool paramUseISO19005_1 = false;

try

{

// 開啟來源檔案

wordDocument = wordApplication.Documents.Open(ref paramSourceDocPath, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing);

// 匯出選定格式檔案

if (wordDocument != null)

wordDocument.ExportAsFixedFormat(paramExportFilePath, paramExportFormat,

相关文档
最新文档