使用FlashPrinter将word,excel,pdf转换成swf失败的问题
我在ASP.NET程序中使用FlashPrinter.exe将word,excel,pdf,ppt转换成swf,在本地运行
(localhost)时,全部能转换成功,但是放在IIS上,却只有pptx能转换成功,其中在转换docx和
xlsx的文件时,直接卡死。而转换pdf却执行完毕后没有生成swf文件。
我已经将FlashPrinter.exe所在文件夹赋予了权限,Network Service账号添加至administrators
组,IIS的应用程序池中的标识预定义账户修改成本地系统。并且在IIS上能转换pptx,应该不是权
限问题。我写了两个方法,但是两个方法都出现这样的问题,代码如下,在线等,有答案马上结
贴,本人结贴率100%。谢谢了!
private void ConvertSwf(string inputPath, string outputPath)
{
Process p = new Process();
try
{
p.StartInfo.FileName = "cmd.exe";
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 inputPath = Server.MapPath("~//11.docx");
//string outputPath = Server.MapPath("~//11.swf");
//D:\Asp.NetPro\PPTToSwf\swftools\FlashPaper\FlashPaper2.2\\FlashPrinter.exe
//D:\\Asp.NetPro\\PPTToSwf\\swftools\\FlashPaper2.2\\FlashPrinter.exe
string s = "D:\\Asp.NetPro\\PPTToSwf\\swftools\\FlashPaper\\FlashPaper2.2\\FlashPrinter.exe "
+ "\"" + inputPath + "\" -o \"" + outputPath + "\"";
p.StandardInput.WriteLine(s);
p.StandardInput.WriteLine("exit");
strOutput = p.StandardOutput.ReadToEnd();
Console.WriteLine(strOutput);
p.WaitForExit();
p.Close();
}
catch (Exception ex)
{
}
}
public void ConvertToSWF(string oldFile, string swfFile) // oldFile格式a.doc newFIle格式 b.swf
{
System.Diagnostics.Process pc = new System.Diagnostics.Process();
pc.StartInfo.FileName = @"D:\\Asp.NetPro\\PPTToSwf\\swftools\\FlashPaper2.2\\FlashPrinter.exe "; //默认安装目录
pc.StartInfo.Arguments = string.Format("{0} -o {1}", oldFile, swfFile); //调用FlashPrinter的命令
pc.StartInfo.CreateNoWindow = true; //不创建窗口
pc.StartInfo.UseShellExecute = false; //不使用系统外壳程序启动
pc.StartInfo.RedirectStandardInput = false; //不重定向输入
pc.StartInfo.RedirectStandardOutput = false; //不重定向输出
pc.StartInfo.RedirectStandardError = true;
pc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
pc.Start();
pc.WaitForExit();
pc.Close();
pc.Dispose();
}
[解决办法]
FlashPrinter好像不支持64位的。
服务器中写入swf的目录权限,是服务器那台计算机名用户上勾选写入权限,默认的没有。
前几天试过这个,也总有些问题(主要是操作系统不同),后来全部转成PDF,再转成SWF显示的。
[解决办法]
在客户端做吧。不要在服务器上随便安装这种程序,否则多好的服务器都要完。
[解决办法]
在服务器上安装Office、安装其它许多COM组件、手工注册好几个组建、还要去手工修改一些“权限”.......
这是在做第一个项目时拿用户练手可以。如果做产品,那么这些都应该废弃,应该重新设计产品架构。
[解决办法]
需要手动转成pdf文档用pdf factory pro或者office的一个插件,可以把office文档直接另存为pdf。然后用swftools转成swf格式,用flexpaper显示出来。查一下,很好做,网上都有。