磁条印刷:从哪里开始? [英] Magnetic stripe printing: Where to start?

查看:103
本文介绍了磁条印刷:从哪里开始?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是与ID卡打印相关的WPF桌面应用程序.我们尝试添加的新功能之一是磁条编码.花了几天的时间后,我仍然不确定从哪里开始.谷歌搜索更多新问题.我在这里总结一下.我很高兴收到专家的来信(即使有人可以回答一个/某些问题):

This is a WPF desktop app related to ID Card printing. One of the new features we're trying to add is magstripe encoding. After having spent several days, I'm still not sure where to start. New questions keep popping up the more I google. I'll summarize them here. I'll be glad to hear from experts (even if someone can answer one/some of the questions):

  1. 磁条式打印机是否也像普通打印机一样工作(这意味着它们也可以打印文本和图形,或者我们是在第一遍中在其他普通打印机上打印卡,然后将其插入磁条式打印机中以对磁数据进行编码) ,在第二阶段)?
  2. 如果对Q1的回答是肯定的,我如何在常规打印作业期间(通过WPF,使用PrintDialogFixedDocument等完成)将磁条数据发送到打印机.
  3. 我下载并检查了Zebra打印机SDK.看起来这些打印机除了磁条编码外还支持文本/图形打印,但是他们的SDK要求我调用其本机打印功能,这不适合WPF的标准打印模型.如何克服这个问题?
  1. Do magstripe printers work as normal printers too (means can they print text and graphics too, or is that we print the cards on other, regular printers in the first pass and then insert them into magstripe printer for encoding magnetic data onto them, in the 2nd pass)?
  2. If answer to Q1 is yes, how do I send magstripe data to the printer during regular printing job (done through WPF, using PrintDialog, FixedDocument etc).
  3. I downloaded and examined Zebra printers SDK. It looks like these printers DO support text/graphics printing in addition to magstripe encoding, but their SDK requires me to call their native printing functions, which doesn't fit in WPF's standard printing model. How to overcome this?
  4. In another place I read that magstripe printers require simple ASCII text in specific format to get them encoded onto the card, and that I can do this even from Notepad. If this is true, the answer to Q1 might be negative. But then again, how does this method work in conjunction with regular WPF printing?

编辑

  1. 我也了解到放置在文档中的字体最终被编码为磁条,而不是常规打印.如果是这样,它将非常适合WPF打印模型.但是谷歌搜索并没有为磁条字体返回太多有希望的结果.也许这是特定于品牌的功能.
  1. I also learnt that there are magstripe fonts that when placed in a document, end up being encoded to the magnetic stripe instead of regular printing. If this is true, it would very nicely fit in WPF printing model. But googling hasn't returned too many promising results for magstripe fonts. Maybe this is a brand-specific feature.

推荐答案

我目前正在从事类似的WPF项目,该项目需要磁编码以及ID卡上的图像打印.我发现只要在主机上安装了具有磁性编码的打印机驱动程序,磁性编码就非常简单.需要注意的一个重要方面是驾驶员使用的定界符.可以为NULL,零或空格.在对特定音轨(即音轨2而不是我们的音轨1)进行编码时,这会起作用.我使用NULL设置,该设置仅允许在作业中发送Track 2数据.在Fargo打印机的打印机首选项中可以找到此设置(控制面板->硬件和声音->设备和打印机->右键单击打印机->打印机首选项).这是这些首选项的示例(请注意ASCII偏移字段):

I am currently working on a similar WPF project that requires magnetic encoding as well as image printing on ID cards. I have found that magnetic encoding is very simple as long as the drivers for the printer with magnetic coding are installed on the host. One vital piece to watch out for is the delimiter being used by the driver. This could be NULL, ZERO, or Space. This comes into play when encoding a specific track (i.e. Track 2 but not Track 1 as we are). I use the NULL setting which allows only the Track 2 data to be sent in the job. This setting is found in the Printer Preferences for the Fargo printers (Control Panel -> Hardware and Sound -> Devices and Printers -> Right-Click Printer -> Printer Preferences). Here is an example of these Preferences (note the ASCII Offset field):

我不认为您必须为要使用的打印机使用SDK.我使用的是Fargo打印机,但是使用PrintDocument和PrintPage编写了自己的打印功能,用于磁性编码和图像.

I do not believe that you MUST use the SDK for the printer you are using. I am using a Fargo printer but wrote my own Print functionality using PrintDocument and PrintPage for both magnetic encoding and images.

一个示例和快速测试是使用Notepad ++(或类似版本)将Track 2数据发送到打印机.将其复制并粘贴到编辑器的第一行并进行打印(使用证卡打印机).

An example and quick test is to send Track 2 data to the printer using Notepad++ (or similar). Copy and paste this into the first line of the editor and print (using the card printer).

~2;000099990000?

驱动程序应了解它是跟踪数据"这一事实,并进行相应处理,而无需您提供任何其他输入.您可能需要按照说明使用打印机首选项.

The driver should pick up the fact that it is Track data and handle it accordingly without any more input from you. You may need to play with the printer preferences as stated.

〜2;表示轨道2,后跟12个字符的数据字符串,后跟末尾(?).有很多有关在线跟踪数据和布局的文档.这是假设定界符值为NULL(在Track 1和Track 2之间).

The ~2; denotes Track 2 followed by a 12-character data string followed by the end sentinel (?). There is plenty of documentation pertaining to Track data and layouts online. This is assuming a NULL delimiter value (between Track 1 and Track 2).

在卡的两面打印可能很麻烦,但这似乎不在此问题的范围内.我建议在WPF应用程序中使用Windows本机的PrintDocument和PrintPage方法.您下载的SDK可能会在后台使用这些方法.

Printing on both sides of the card can be cumbersome, but that does not appear to be within the scope of this question. I recommend using Windows native PrintDocument and PrintPage methods within your WPF application; the SDK you have downloaded is likely using these methods in the background, anyhow.

PrintDocument/PrintPage的示例:

An example of PrintDocument/PrintPage:

private int PageCount { get; set; }

public void Print()
{
PageCount = 0;

PrintDocument pd = new PrintDocument
{
    // Define your settings
    PrinterSettings = {
        Duplex = Duplex.Horizontal,
        PrinterName =  ConfigurationManager.AppSettings["PrinterName"]
    }
};

Margins margins = new Margins(0, 0, 0, 0);
pd.OriginAtMargins = true;
pd.DefaultPageSettings.Margins = margins;

pd.PrintPage += new PrintPageEventHandler(this.PrintPage);

PrintPreviewDialog ppd = new PrintPreviewDialog();

ppd.Document = pd;

// Uncomment to show a Print Dialog box
//if (ppd.ShowDialog() == DialogResult.OK)
    pd.Print();

pd.Dispose();
}

private void PrintPage(object o, PrintPageEventArgs e)
{
PrintDocument p = (PrintDocument)o;

p.DefaultPageSettings.Landscape = true;
p.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0);
p.DefaultPageSettings.PaperSize = new PaperSize("YourPaperSizeName", 340, 215);
p.OriginAtMargins = true;

o = p;

e.PageSettings.PrinterSettings.DefaultPageSettings.Landscape = true;
e.PageSettings.Landscape = true;

// Do Print First Side (MAG ENCODE)
if (PageCount == 0)
{
    // Do Side 1 Stuff

    // If Two-Sided Printing: true
    e.HasMorePages = true;
//If no more, set above to false and PageCount = 0, else...
    PageCount++;
}
else
{
    // Do Print on Other Side
    // STUFF
    // STUFF

    // Since only two sides/card printing: false
    e.HasMorePages = false;
    PageCount = 0;
}
}

同样,磁编码不应该是特定于品牌的,并且您不必不必完全依靠其SDK来执行打印作业.

Again, magnetic encoding should not be brand-specific and you should not have to rely solely on their SDK to perform print jobs.

我希望这会有所帮助!

这篇关于磁条印刷:从哪里开始?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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