• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C#将office文档转成swf的另一解决法案----FlashPaper的打印功能

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
<%@ WebHandler Language="C#" Class="UploadHandler" %>

using System;
using System.IO;
using System.Web;
using System.Data.SqlClient;

public class UploadHandler : IHttpHandler {

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        context.Response.Charset = "utf-8";
        HttpPostedFile file = context.Request.Files["Filedata"];        
        string fileName=file.FileName;
        string extensionName = fileName.Substring(fileName.LastIndexOf('.'));
        string reFileName = DateTime.Now.ToString("yyyyMMddHHmmssfff");
        string folder = @context.Request["folder"];
        string uploadPath = HttpContext.Current.Server.MapPath(folder) + "\\";        
        if (file != null)
        {
            if (!Directory.Exists(uploadPath))
            {
                Directory.CreateDirectory(uploadPath);
            }
            file.SaveAs(uploadPath + reFileName + extensionName);
            DBUtility.DbHelperSQL.ExecuteSql("insert into ok_docs_file(docs02,docs03,docs04) values(@docs02,@docs03,getdate())", new SqlParameter("@docs02", fileName), new SqlParameter("@docs03", folder + "/" + reFileName + ".swf"));            
            //下面这句代码缺少的话,上传成功后上传队列的显示不会自动消失
            ConvertToSWF(uploadPath + reFileName + extensionName, uploadPath+ reFileName + ".swf");
            context.Response.Write("1");
                 
        }
        else
        {
            context.Response.Write("0");
        }
        
    }
    public void ConvertToSWF(string oldFile, string swfFile)
    {
        System.Diagnostics.Process pc = new System.Diagnostics.Process();
        pc.StartInfo.FileName = @"E:\oaoffice\Web\FlashPaper2.2\FlashPrinter.exe";//安装路径        
        pc.StartInfo.Arguments = string.Format("{0} -o {1}", oldFile, swfFile);
        pc.StartInfo.CreateNoWindow = true;
        pc.StartInfo.UseShellExecute = false;
        pc.StartInfo.RedirectStandardInput = false;
        pc.StartInfo.RedirectStandardOutput = false;
        pc.StartInfo.RedirectStandardError = true;
        pc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
        pc.Start();
        pc.WaitForExit();
        pc.Close();
        pc.Dispose();
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}

源码下载:http://pan.baidu.com/share/link?shareid=2513136070&uk=3289148388


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C#数据库操作类发布时间:2022-07-10
下一篇:
C#读书笔记:线程,任务和同步发布时间:2022-07-10
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap