我有一个项目需要使用pdf2swf来转换pdf到swf。我在windows上使用swftool 0.9.1。文件pdf2swf.exe在上传文件夹中。我想要自动转换。我在Asp.net开发服务器上使用它。我使用以下代码:
protected void Page_Load(object sender, EventArgs e)
{
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.WorkingDirectory = HttpContext.Current.Server.MapPath("~");
p.StartInfo.FileName = HttpContext.Current.Server.MapPath("~/upload/pdf2swf.exe");
p.StartInfo.Arguments = " -b " + "alo.pdf" + " -o " + "alo" + ".swf";
//Start the process
p.Start();
TextBox1.Text = p.StandardOutput.ReadToEnd();
TextBox2.Text = p.StandardError.ReadToEnd();
p.WaitForExit();
p.Close();
}当我在浏览器中查看此页面时,此页面显示正常,没有错误。但最重要的是文件.swf,而不是创建。请帮我解决这个问题!谢谢你的帮忙!我尝试从web应用程序运行pdf2swf。当我在浏览器中查看此页面时,字符串错误输出为: Error: open‘t open file 'alo.pdf’。但它是存在的。
发布于 2013-04-01 20:50:57
确保p.StartInfo.WorkingDirectory指向pdf文件所在的目录。如果这些文件在上载目录中,那么它应该是:
p.StartInfo.WorkingDirectory = HttpContext.Current.Server.MapPath("~/upload");此属性指定pdf2swf的工作目录(默认目录,如果未指定路径,则pdf2swf将在其中搜索文件)。目前它将在HttpContext.Current.Server.MapPath("~")目录中搜索PDF文件。
https://stackoverflow.com/questions/15737569
复制相似问题