• 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

  • 相关阅读:
    Cocos2d-x教程(34)-三维物体OBB碰撞检測算法
    POJ 2485 Highways 最小生成树 (Kruskal)
    LintCode-分糖果
    云存储市场布局已定,怎样助力企业互联网转型
    HDU 1853 Cyclic Tour(最小费用最大流)
    windows下基于bat的每1分钟执行一次一个程序
    python中匹配中文,解决不匹配,乱码等问题
    bytes,packet区别 字节数据包
    wmic
    paramiko 模块封装
  • 原文地址:https://www.cnblogs.com/iwenwen/p/3129313.html
Copyright © 2020-2023  润新知