[英]Printing with Silverlight and com-interop
I'm trying to print from silverlight without a print dialog and for that I'm using System.Runtime.InteropServices.Automation; 我正在尝试从没有打印对话框的silverlight打印,因为我正在使用System.Runtime.InteropServices.Automation;
Right now I'm creating a temporary txt file that contain the text to send to printer. 现在我正在创建一个包含要发送到打印机的文本的临时txt文件。
using (dynamic fso = AutomationFactory.CreateObject(@"Scripting.FileSystemObject"))
{
dynamic file = fso.CreateTextFile(cFileName, true);
file.Write(printText);
file.Close();
}
After that I'm using shell.Aplication to print that document. 之后我使用shell.Aplication打印该文档。
dynamic shell = AutomationFactory.CreateObject("Shell.Application");
shell.ShellExecute(cFileName, "", "", "print", 1);
The question is, how can a print directly to printer without a temporary txt file? 问题是,如何在没有临时txt文件的情况下直接打印到打印机?
Don't forget that I'm using Silverlight 4 out of browser and with elevated trust. 不要忘记我正在使用浏览器中的Silverlight 4并提升信任度。
You should be able to start notepad and send your content although this is no fun solution: 您应该能够启动记事本并发送您的内容,尽管这不是一个有趣的解决方案:
Read: Silverlight 4 - send text to Notepad and: http://msdn.microsoft.com/en-us/library/8c6yea83(v=vs.85).aspx 阅读: Silverlight 4 - 将文本发送到记事本和: http : //msdn.microsoft.com/en-us/library/8c6yea83(v = vs。85).aspx
So basicly, 1. you start an instance of notepad. 所以基本上,1。你启动一个记事本实例。 2. Wait some time.
等一下。 3. Send your text to notepad 4. Send {PRTSC} for printing 5. Ofcourse, close the instance ;)
3.将文本发送到记事本4.发送{PRTSC}进行打印5.当然,关闭实例;)
Good luck! 祝好运!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.