zoukankan      html  css  js  c++  java
  • C#代码使用Process类调用SWFTools工具

    一。Process类调用SWFTools工具将PDF文档转为swf文档

    1
    string cmdStr = "D:\SWFTools\pdf2swf.exe"; 2 string PDFPath = HttpContext.Current.Server.MapPath("PDFFile/liuzeliang.pdf"); 3 string SWFPath = HttpContext.Current.Server.MapPath("SWFFile"); 4 string args = " -o "+"""+SWFPath+"\liuzeliang.swf"+"""+ " -s flashversion=9 " + """+ PDFPath+"""; 5
    using (Process p = new Process())
                {
                    try
                    {
                        p.StartInfo.FileName = cmdStr;
                        p.StartInfo.Arguments = args;
                        p.StartInfo.UseShellExecute = false;         //不使用系统外壳程序启动
                        p.StartInfo.RedirectStandardInput = true;
                        p.StartInfo.CreateNoWindow = false;
                        p.Start();
                        //p.StandardInput.WriteLine(args);
                        p.WaitForExit();
                        if (p != null)
                        {
                            p.Close();
                        }
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }
    遇到的问题大概如下(swftools-0.9.0  Windows版本 官网下载地址:http://www.swftools.org/download.html):
    1.调用pdf2swf.exe将pdf转swf失败。
          原因:swf文件存放路径含义空格(红色部分D:Userszeliang.liuDocumentsVisual Studio 2015ProjectsFlexPaperTestFlexPaperTestSWFFile)
    解决方法:给整个路径用双引号括起来。(红色部分:string args = " -o "+"""+SWFPath+"\liuzeliang.swf"+"""+ " -s flashversion=9 " + """+ PDFPath+""";)
    2.转换成功后调用FlexPaper无法显示。
          原因:swf文件版本问题。
          解决方法:在传入process的参数里加入 -s flashversion=9 注意=前后不要有空格。(其实我刚开始用的-T并不能成功显示)
    
    

    二。利用flexpaper插件显示swf文件

      
    1.先下载好flexpaper的.rar包,然后将包中的js复制到项目中在引用下面俩个js到页面(我的flexpaper是1.4.5版本的)

    2.将文件夹中的FlexPaperViewer.swf放到项目中去
    <script src="scripts/flexpaper/jquery.js"></script>
    <script src="scripts/flexpaper/flexpaper_flash.js"></script>
    
    
    

    1
    <a id="viewerPlaceHolder" style="660px;height:480px;display:block"></a> 2 <script type="text/javascript"> 3 var swfFile = "SWFFile/liuzeliang.swf"; 4 var fp = new FlexPaperViewer( 5 ///FlexPaper组件的SWF框架路径 6 'scripts/flexpaper/FlexPaperViewer', 7 'viewerPlaceHolder', 8 { 9 config: 10 { 11 ///需要显示的.swf 12 SwfFile: escape(swfFile), 13 Scale: 0.6, 14 ZoomTransition: 'easeOut', 15 ZoomTime: 0.5, 16 ZoomInterval: 0.2, 17 FitPageOnLoad: false, 18 FitWidthOnLoad: false, 19 PrintEnabled: true, 20 FullScreenAsMaxWindow: false, 21 ProgressiveLoading: false, 22 MinZoomSize: 0.2, 23 MaxZoomSize: 5, 24 SearchMatchAll: false, 25 InitViewMode: 'Portrait', 26 ViewModeToolsVisible: true, 27 ZoomToolsVisible: true, 28 NavToolsVisible: true, 29 CursorToolsVisible: true, 30 SearchToolsVisible: true, 31 localeChain: 'en_US' 32 } 33 }); 34 35 </script>
    
    
    

    
    
    
    

     

  • 相关阅读:
    Spring AOP获取拦截方法的参数名称跟参数值
    mybatis generator逆向工程自动生成带中文注释修改版(添加了实体类注释)文末附有git下载地址
    关于Java编写多行注释遇到方法字符串中正好也有注释符号产生冲突的解决办法
    SpringBoot入门学习以及整合MyBatis
    IO跟NIO的区别
    redis的配置文件详解redis.conf
    Redis入门基础内容(转载整理非原创)
    深入网络协议来理解数据传输三(http协议详解)
    深入网络协议来理解数据传输二(转载整理)
    Python编写ATM(初级进阶)
  • 原文地址:https://www.cnblogs.com/OraCursor/p/7744635.html
Copyright © 2011-2022 走看看