[英]How to programatically send openoffice writer odt file to printer from C# Windows Forms Application
I'd like to send an OpenOffice writer document to the default printer from within a C# WinForms application. 我想从C#WinForms应用程序中将OpenOffice编写器文档发送到默认打印机。 The purpose is to print customer receipts.
目的是打印客户收据。 I plan on opening a prepared OpenOffice file, substitute dynamic customer information and then print the modified document.
我计划打开准备好的OpenOffice文件,替代动态客户信息,然后打印修改后的文档。 It is important that OO not necessarily be installed so solutions which depend on OO or open up an OO prompt won't work.
重要的是,不一定要安装OO,这样依赖于OO或打开OO提示的解决方案将无法工作。 Any suggestions would be appreciated.
任何建议,将不胜感激。
I too use open office for printing customer generated invoices, I do so in bulk and below is the method that I use. 我也使用开放式办公室打印客户生成的发票,我这样做是批量的,下面是我使用的方法。
What you are seeking is achievable by using "ProcessStartInfo" from the Systems.Diagnostics namespace found here: https://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo(v=vs.110).aspx 通过使用Systems.Diagnostics命名空间中的“ ProcessStartInfo”,可以在此处找到所需的内容: https ://msdn.microsoft.com/zh-cn/library/system.diagnostics.processstartinfo( v= vs.110).aspx
the important part is ensuring you have set "CreateNoWindow" to true as well as settings the "WindowStyle" to "ProcessWindowStyle.Hidden". 重要的部分是确保将“ CreateNoWindow”设置为true以及将“ WindowStyle”设置为“ ProcessWindowStyle.Hidden”。
Simply pass in the location of the file to print, and ensure you include the file extension after the location. 只需输入要打印的文件的位置,并确保在该位置之后包括文件扩展名即可。 I use this snippet regularly so if you have any problems just let me know.
我会定期使用此代码段,因此,如果您有任何问题,请告诉我。
void printDoc(String fileLocation) {
ProcessStartInfo info = new ProcessStartInfo(fileLocation);
info.Verb = "print";
info.CreateNoWindow = true;
info.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(info);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.