• 解决:通过asp.net 调用FlashPrinter.exe把所有可打印的文件转换成swf文件



    FlashPaper干嘛用的?加个连接:http://apps.hi.baidu.com/share/detail/14456532

    FlashPaper是一个虚拟打印机,可将word文件转化成swf格式文件(.doc .xls .txt .pdf等文件都可以正常生成SWF格式)。最近简单学习了在ASP.NET页面中调用FlashPaper将word文件转化成swf格式文件的方法。

    (1)安装FlashPape:下载FlashPape压缩包,解压缩后,运行初始化目录中的初始化.bat,然后安装FlashPaperDriverInstall2.exe,即FlashPaper打印机。特别注意,在有的机器上要更改Macromedia FlashPape的端口,应为FlashPape2PrinterPort,如果是LPT1这个端口,当然打印不出来了。

    (2)为页面中的按钮编写事件处理代码:

    程序代码 程序代码
    Process process = new Process();     //创建进程对象
            //try
            //{
                ProcessStartInfo startInfo = new ProcessStartInfo();
                string paperroot = @"C:\Program Files\Macromedia\FlashPaper 2\FlashPrinter.exe";
                string docFile = Server.MapPath("1.doc");
                string swfFile = Server.MapPath("1.swf");

                startInfo.FileName = paperroot;
                startInfo.Arguments = docFile + " -o " + swfFile;
                startInfo.UseShellExecute = false;     //不使用系统外壳程序启动
                startInfo.RedirectStandardInput = false;   //不重定向输入
                startInfo.RedirectStandardOutput = false;   //重定向输出
                startInfo.CreateNoWindow = true;     //不创建窗口
                process.StartInfo = startInfo;

                process.Start();


                Response.Write("已经提交生成。<br />");
                Response.Write(paperroot+"<br />"+docFile + " = " + swfFile);
            //}
            //catch (Exception ex)
            //{
            //    Response.Write(ex.Message);
            //}
            //finally
            //{
                if (process != null)
                    process.Close();

            //    Response.Write("<br />finally");
            //}



    注意:有人说,FlashPrinter.exe所在的目录名称中不能有空格,否则转换失败。其实我上面的不不带空格了它同样转换成功了。

    还碰到权限问题,简单的解决方法如下:

         在Windows xp系统下请把aspnet账号(如果是vista,则是networkservice)添加至administrators组,并重启iis admin服务。

         在 windows server 2003下不用说了吧。一样是 networkservice 并重启iis admin服务。就这样问题搞了我半夜半天。

  • 相关阅读:
    Navicat建表MySQL索引类型
    Feign调用全局异常处理解决
    ShardingJDBC、Mycat、drds对比
    MySQL之索引失效分析及优化相关
    SpringBoot2.X集成spring session redis实现session共享
    Redis的消息订阅/发布 Utils工具类
    MySQL索引类型区分
    handler使用(二)
    Android开发指南中文版(七)Content Providers
    Android消息处理(一)进程内通信
  • 原文地址:https://www.cnblogs.com/sontin/p/1929788.html
Copyright © 2020-2023  润新知