C#中的点阵打印? [英] Dot Matrix printing in C#?

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

问题描述

我正在尝试使用 C# 打印到点阵打印机(各种型号),目前我正在使用 Win32 API(您可以在网上找到很多示例)调用将转义码直接发送到我的 C# 中的打印机应用.这很好用,但是...

I'm trying to print to Dot Matrix printers (various models) out of C#, currently I'm using Win32 API (you can find alot of examples online) calls to send escape codes directly to the printer out of my C# application. This works great, but...

我的问题是因为我正在生成转义码并且不依赖于 Windows 打印系统,所以打印输出无法发送到任何普通"打印机或 PDF 打印驱动程序之类的东西.(这现在导致了一个问题,因为我们正在尝试使用 Easy Print [基于 XPS] 在 2008 终端服务器上使用该应用程序)

My problem is because I'm generating the escape codes and not relying on the windows print system the printouts can't be sent to any "normal" printers or to things like PDF print drivers. (This is now causing a problem as we're trying to use the application on a 2008 Terminal Server using Easy Print [Which is XPS based])

问题是:如何在不使用直接打印、转义码等的情况下,使用 C# 将格式化的文档(预印文具上的发票)打印到点阵打印机(爱普生、Oki 和松下……各种型号).

The question is: How can I print formatted documents (invoices on pre-printed stationary) to Dot Matrix printers (Epson, Oki and Panasonic... various models) out of C# not using direct printing, escape codes etc.

**澄清一下,我正在尝试 GDI+ (System.Drawing.Printing) 之类的东西,但问题是它很难像旧代码一样排列整齐.(旧代码绕过 Windows 驱动程序将字符直接发送到打印机.)有什么建议可以改进,以便他们可以使用 GDI+ 但仍然像旧代码一样排列?

**Just to clarify, I'm trying things like GDI+ (System.Drawing.Printing) but the problem is that its very hard, to get things to line up like the old code did. (The old code sent the characters direct to the printer bypassing the windows driver.) Any suggestions how things could be improved so that they could use GDI+ but still line up like the old code did?

推荐答案

您可能应该使用报告工具来制作模板,使您或用户能够正确定位与预印信纸相关的字段.

You should probably use a reporting tool to make templates that allow you or users to correctly position the fields with regards to the pre-printed stationery.

使用点阵打印机,您基本上必须以两种模式之一工作:

Using dot-matrix printers, you basically have to work in either of 2 modes:

  • 行/列文本的简单打字机模式,您可以发送转义序列来管理打印机硬件中包含的少量字体,并且必须管理换行等.
  • 页面被光栅化的图形输出,打印机驱动程序只驱动打印头和引脚输出点.

第一种用法在 Windows 下大多被弃用,因为它没有提供太多控制输出的方式,而且每台打印机都有自己的特性,软件变得笨拙且难以预测页面上的内容(不所见即所得).

The first usage is mostly deprecated under Windows as it does not offer much in the way of controlling the output, and each printer having its own characteristics it becomes unwieldy and difficult for the software to predict and position things on the page (no WYSIWYG).

第二种只是使用图形页面范例,使定位文本和图形独立于打印机的实际功能.
使用预印信纸时,您的作业需要正确定位页面上的数据.
手动执行此操作会消耗资源,并且当然不建议在代码中创建布局,因为如果打印机、页面格式或打印的信纸发生变化,您将不得不修改代码.

The second just uses a graphic page paradigm that makes positioning text and graphics independent of the actual capabilities of the printer.
When using pre-printed stationery, your job s to correctly position the data on the page.
Doing this by hand is resource-consuming and creating the layout in code is certainly not recommended since you'll get stuck with code to change should your printer, page format or printed stationery change.

最好只使用 .Net 提供的标准打印模型和报告工具,该工具允许您定义模型和模板以放置正确的文本和图形,然后从代码中进行驱动.

The best is to just use the standard printing model offered by .Net and a reporting tool that allows you to define models and templates where the correct text and graphics will be positioned, and then drive this from code.

Visual Studio 附带一个 Crystal Reports 版本,但还有其他更好的报告系统(我使用的是 developer express 例如),其中一些甚至是免费.

Visual Studio is shipped with a version of Crystal Reports but there are other, better reporting systems (I use the one from developer express for instance), some of them are even free.

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

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