简体   繁体   English

使用Silverlight和com-interop进行打印

[英]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.

相关问题 COM-Interop中的十进制封送处理 - Decimal marshaling in COM-Interop 使用COM-Interop将数组从JS返回到C# - Returning an array from JS to C# with COM-Interop 如何将暴露给COM-interop的.NET对象标记为单线程? - How to mark .NET objects exposed to COM-interop as single threaded? 使用com-interop将数组从vba传递给c# - Pass an array from vba to c# using com-interop COM-Interop, EAccessViolation 在我退出应用程序后 - COM-Interop, EAccessViolation after i exit the Application 在2个解决方案之间,用于C ++ COM dll的C#COM-Interop dll不起作用 - C# COM-Interop dll for C++ COM dll doesn't work between 2 solutions 如果在 vs 中构建的项目属性下设置了 com-interop,则无法注册用于 db 迁移的 .Net 程序集 - .Net assembly for db migration can't be registered if com-interop is set under project properties build in vs 该错误的常见来源包括COM-interop或Pinvoke的用户封送处理错误,这可能会破坏堆栈 - Common Sources of this bug include user marshaling error for COM-interop or Pinvoke, which may corrupt the stack COM-Interop程序集在从Vb调用时未找到本机(.Net)依赖性 - COM-Interop assembly not finding a native (.Net) dependancy when called from Vb C ++ / CLI com-Interop:向VBA公开引用类型属性 - C++/CLI com-Interop: Exposing a reference type property to VBA
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM