我在桌面上的文件夹中安装了Apache FOP。我有一个C#.NET应用程序,它接受样式表和xml文件,然后将这些作为参数传递给命令行,然后由Apache FOP处理它们。
命令行打开,但没有任何反应。
这是我的代码:
private void OpenCommandLine(string XSL_As_Param,string XML_As_Param)
{
try
{
Textfield.AppendText("Transformation started\n");
commandlineargs = @"fop -xml Stuff\\"+XML_As_Param+" -xsl Stuff\\"+XSL_As_Param+" -pdf output.pdf -c conf/fop.xconf";
startInfo.FileName = "cmd.exe";
startInfo.Arguments = commandlineargs;
process.StartInfo = startInfo;
process.Start();
}
catch (Exception e)
{
Textfield.AppendText(e.StackTrace);
Textfield.AppendText(e.Message);
}
finally
{
Textfield.AppendText("\n\nTransformation done\n");
process.Close();
}
}
另外,命令行参数是
"fop -xml Stuff\\\\Sicherheitshinweise.xml -xsl Stuff\\stylesheet.xsl -pdf output.pdf -c conf/fop.xconf"
" \\\\"和" \\"来自?难道他们不能逃到\? (我在Windows 7上) XML_As_Param和XSL_As_Param具有正确的值(只是文件名加扩展名)
Thanx为你提供帮助!
答案 0 :(得分:0)
我知道了:
private void OpenCommandLine(string XML_As_Param, string output)
{
try
{
Textfeld1.AppendText("\n\nTransformation started\n");
MyBatchFile = @"transform.bat";
XML_filename = @"" + XML_As_Param + "";
XSL_filename = @"stylesheet.xsl";
this.output = @"" + output + "";
process = new Process { StartInfo = { Arguments = string.Format("{0} {1} {2}", XML_filename, XSL_filename, output) } };
process.StartInfo.FileName = MyBatchFile;
process.Start();
}
catch (Exception e)
{
Textfeld1.AppendText(e.StackTrace);
Textfeld1.AppendText("\n");
Textfeld1.AppendText(e.Message);
}
finally
{
process.Close();
}
}
批处理文件:
@echo off
cd pathfofop\FOP
fop -xml %1 -xsl ..\stylesheets\%2 -pdf %3.pdf -c conf\fop.xconf