zoukankan      html  css  js  c++  java
  • C#将office文档转成swf的另一解决法案FlashPaper的打印功能

    <%@ 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

  • 相关阅读:
    实现h5中radio单击取消与选中
    小程序中的组件化理解
    阿里字体css代码引入方法
    前端布局心得小结
    Python学习资源汇总,转载自他人
    史上最全 原生javascript的知识总结,适合新手及查资料用!
    windows Python 3.4.3 安装图文
    PyInstaller编译python3时使用的详细参数介绍
    PyInstaller 安装方法 及简单的编译exe (python3)
    Windows 安装 GTK+ 图文说明
  • 原文地址:https://www.cnblogs.com/iwenwen/p/3129313.html
Copyright © 2011-2022 走看看