我需要从 SharePoint 工作流中打开一个 Word 文档,并将其打印到特定的打印机托盘。我首先尝试使用 Word.Interop 创建一个 Word 应用程序实例,但是我的 doc 对象总是返回 null。我已经读到这不是 WordInterop 的受支持使用。所以现在我正在寻找替代品
我编写了一个简单的控制台应用程序,它接受 word 文档、打印机名称和托盘号作为参数。控制台应用程序在命令提示符下运行良好,但我无法从 SharePoint 工作流 CodeActivity 调用它
string urlWord = GetwordDocument(printType);
System.Diagnostics.Process prcs = new System.Diagnostics.Process();
prcs.StartInfo.FileName = @"c:\DocxPrint2Tray.exe";
prcs.StartInfo.Arguments = String.Format(" \"{0}\" \"{1}\" \"{2}\" ",urlWord, printerName, printerTray);
prcs.StartInfo.UseShellExecute = false;
prcs.StartInfo.RedirectStandardOutput = true;
prcs.Start();
string prcsOut = prcs.StandardOutput.ReadToEnd();
prcs.WaitForExit();
代码似乎挂在prcs.StandardOutput.ReadToEnd()行。SharePoint 工作流是否支持调用外部进程?对任何代码建议和替代解决方案开放。
提前致谢