日期:2014-05-17  浏览次数:20786 次

将pdf转换为swf并显示在网页中
我是用flexpaper+swftools在线阅读pdf,用网上下载的列子把pdf上传后查看可以打开,但是我自己的代码直接给出路径转换不了,运行后控件框可以出来,pdf内容显示不出来

public string FileURL
    {
        get;
        set;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        string fileName = "iop.pdf";
        string cmdStr = HttpContext.Current.Server.MapPath("~/SWFTools/pdf2swf.exe");
        string savePath = HttpContext.Current.Server.MapPath("~/TestSWF/");
        // @"""" 相当于一个双引号,之所以要加@"""" 就是为了防止要转换的过程中,文件夹名字带有空格,导致失败
        string sourcePath = @"""" + savePath + fileName + @"""";
        string targetPath = @"""" + savePath + fileName.Substring(0, fileName.LastIndexOf(".")) + ".swf" + @"""";
        string argsStr = "  -t " + sourcePath + " -s flashversion=9 -o " + targetPath;
        ExecuteCmd(cmdStr, argsStr);
        FileURL = "iop.swf";
    }

    public static void ExecuteCmd(string cmd, string args)
    {
        using (Process p = new Process())
        {
            ProcessStartInfo psi = new ProcessStartInfo(cmd, args.Replace(" ", ""));
            p.StartInfo = psi;
            p.Start();
            p.WaitForExit();

        }
    }

------解决方案--------------------
首先看看
  string savePath = HttpContext.Current.Server.MapPath("~/TestSWF/");
这文件夹下面生成了swf了没有?如果生成的话。就是在页面显示的路径不对。然后在具体分析。
http://www.cnblogs.com/deoing/archive/2012/02/20/2359054.html
http://yishimengying.blog.163.com/blog/static/101087570201242533919258/
http://www.csharpwin.com/csharpspace/12963r168.shtml