• 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>
    
    
    

    
    
    
    

     

  • 相关阅读:
    Mybatis插入数据时 返回主键
    React 子组件state内数组修改页面不刷新问题
    React 配合echarts使用问题记录
    vue 项目启动报错
    React Ant design table表单与pagination分页配置
    React Cascader组件实现地址选择
    os常用指令
    React 页面间传参
    React Router配置
    react项目 npm run eject报错
  • 原文地址:https://www.cnblogs.com/OraCursor/p/7744635.html
Copyright © 2020-2023  润新知