使用Silverlight和com-interop进行打印 [英] Printing with Silverlight and com-interop

查看:77
本文介绍了使用Silverlight和com-interop进行打印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从Silverlight进行打印而没有打印对话框,为此,我正在使用System.Runtime.InteropServices.Automation;

I'm trying to print from silverlight without a print dialog and for that I'm using System.Runtime.InteropServices.Automation;

现在我创建一个包含要发送到打印机的文本的临时txt文件。

Right now I'm creating a temporary txt file that contain the text to send to printer.

using (dynamic fso = AutomationFactory.CreateObject(@"Scripting.FileSystemObject"))
{
   dynamic file = fso.CreateTextFile(cFileName, true);
   file.Write(printText);
   file.Close();
}

之后,我使用shell.Aplication打印该文档。

After that I'm using shell.Aplication to print that document.

 dynamic shell = AutomationFactory.CreateObject("Shell.Application");
 shell.ShellExecute(cFileName, "", "", "print", 1);

问题是,如何在没有临时txt文件的情况下直接打印到打印机?

The question is, how can a print directly to printer without a temporary txt file?

别忘了我在浏览器中使用Silverlight 4并具有较高的信任度。

Don't forget that I'm using Silverlight 4 out of browser and with elevated trust.

推荐答案

您应该能够启动记事本并发送内容,尽管这不是一个有趣的解决方案:

You should be able to start notepad and send your content although this is no fun solution:

阅读: Silverlight 4-将文本发送到记事本
和: http://msdn.microsoft.com/en-us/library/8c6yea83(v = vs.85) .aspx

基本上,
1.您启动一个记事本实例。
2.等待一段时间。
3.将文本发送到记事本
4.发送{PRTSC}以打印
5.当然,关闭实例;)

So basicly, 1. you start an instance of notepad. 2. Wait some time. 3. Send your text to notepad 4. Send {PRTSC} for printing 5. Ofcourse, close the instance ;)

祝你好运!

这篇关于使用Silverlight和com-interop进行打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆