通过 C# 打印(并行端口)点阵 [英] Printing in (Parallel Port) Dot Matrix over C#

查看:28
本文介绍了通过 C# 打印(并行端口)点阵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于项目的需要,我想在特定位置在 LPT1 上打印,这将在点阵打印机中打印文档,我应该在该位置打印值.我真的很讨厌回去,我不知道从哪里开始.Internet 没有关于使用 C# 在 LPT 端口打印的具体信息,特别是如何在打印时在特定位置发送值.有什么好的例子吗?这个教程?将是一个救星.

解决方案

我可以建议一件事让您的生活更轻松,安装通用文本打印机驱动程序(这是标准配置)并将其设置为 LPT1 端口.然后你可以简单地打开'LPT1'并发送转义码序列来指定字体类型(粗体/斜体)、强调、字体间距等.我不知道是否需要资源.但我想它会是这样的:

<前>System.IO.StreamWriter sr = new System.IO.StreamWriter(@"\.LPT1");sr.Write(0x1b);sr.Write('k');sr.Write('1');sr.Write("你好");//以无衬线字体打印sr.WriteLine();sr.flush();sr.关闭();

资源:

  • 打印到 zebra 打印机 使用 VB.NET(这可以轻松转换为 C# 或将其编译为 DLL 并在您的 C# 项目中引用它)
  • 一篇关于 MSDN 的文章,介绍如何连接到 LPT1
  • 以下是与并口.(进一步向下查看标题为端口 I/O 和中断的编程工具"部分),讨论这个名为 inpout32 的 DLL 的用法.
  • 这是关于 MSDN 的另一篇文章展示了如何进行原始打印.

在 2017-07-12 更新了并行端口链接以使用 Wayback Archive Machine.

For the needs of a project, i want to print over the LPT1 in specific locations, this will print a document in a dot matrix printer where i should print values in the places they should go. I really hate going back, and i don't have any idea where to start. Internet has no specific information about printing in LPT port with C# and especially how to send the values in specific locations while printing. Is there any good example? tutorial for this? would be a life savior.

解决方案

I could suggest one thing to make your life easier, install a generic text printer driver (this comes as standard) and set that to the LPT1 port. Then you can simply open 'LPT1' and send escape code sequences to specify font type (bold/italic), emphasized, font pitch etc. I don't know if the resources would be required. But I would imagine it would be something like this:

System.IO.StreamWriter sr = new System.IO.StreamWriter(@"\.LPT1");
sr.Write(0x1b); sr.Write('k'); sr.Write('1'); sr.Write("Hello"); // print in Sans Serif
sr.WriteLine();
sr.Flush();
sr.Close();

Resources:

  • Printing to a zebra printer using VB.NET (This can be easily translated to C# or compile it to a DLL and reference it in your C# project)
  • An article on MSDN on how to interface to LPT1
  • Here is an extensive list of info pertaining to Parallel Port. (look further down near the section titled 'Programming Tools for Port I/O and Interrupts'), discussing the usage of this DLL called inpout32.
  • Here is another article on MSDN that shows how to do raw printing.

Edited @ 2017-07-12: Updated the Parallel Port link to use the Wayback Archive Machine.

这篇关于通过 C# 打印(并行端口)点阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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