protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { try { System.Diagnostics.Process p = new Process(); p.StartInfo.FileName = "cmd"; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardError = true; p.StartInfo.CreateNoWindow = true; p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; p.Start(); string strOutput = null; string s = @"C:/SWFTools/pdf2swf.exe " + Server.MapPath("~/Files/1.pdf") + " -o " + Server.MapPath("~/Files/1.swf"); p.StandardInput.WriteLine(s); p.StandardInput.WriteLine("exit"); strOutput = p.StandardOutput.ReadToEnd(); Console.WriteLine(strOutput); p.WaitForExit(); p.Close(); lblMessage.Text = "success"; } catch (Exception ex) { lblMessage.Text = ex.ToString(); } } }
其中swftools的安装路径是c:/swftools
上面所得到的swf文件是非常简洁的文件,如果要加入分页还有放大缩小的swf文件,需要重构命令。