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

  • 相关阅读:
    WF4 工作流事件顺序
    审批工作流系统预览
    系统框架最终集大成之——目录
    11.34 为什么框架没有提供代码设计器或代码生成器?
    11.35 如何编写自动任务?
    11.37 如何在系统中记录日志?
    11.38 CastleActiveRecord中如何保证多线程并发操作的安全与成功?
    关于数据库移植方面的记录
    十二、 结语
    datagridview某列编辑时显示为大写
  • 原文地址:https://www.cnblogs.com/iwenwen/p/3129313.html
Copyright © 2011-2022 走看看