C# PrintDocument class and card Encoding

D Davide Rimondi 3 years 7 months ago
195 1 0

Hi All,
  I'm new with Zebra technologies,  for our customer we also handle card printing with magstripe encoding,
currently we are using C# and PrintDocument , now ,since we are going to move on Zebra ZC100 (Firmware 201.01.03)
printers, I'm doing some test.
Unfortunately the same code seems not working on Zebra printer, basically the tracks are printed in front of the card instead
of encoded in the magstripe, 
Could you kindly help me?
Thanks
Davide

the code is pretty sample
private void ZebraPrintingNoSdk(PrintPageEventArgs e)        {            var g = e.Graphics;            SizeF sz = e.Graphics.VisibleClipBounds.Size;            e.Graphics.Clear(System.Drawing.Color.Transparent);                        e.Graphics.RotateTransform(DEGREES);            var track1 = "~1%B" + PrintInfo.AlphaArg1 + "^" +PrintInfo.AlphaArg2  + "^4586540000000000000000000000?";            var track2 = "~2;" + PrintInfo.NumericArg1 + "=99125013800000000?";          //Encoding on magstripe             g.DrawString(track1, new Font("Verdana", 3, System.Drawing.FontStyle.Regular), SystemBrushes.ControlText, 0.0f, -195,new StringFormat() { Trimming = StringTrimming.Character });            g.DrawString(track2, new Font("Verdana", 3, System.Drawing.FontStyle.Regular), SystemBrushes.ControlText, 0.0f, -190, new StringFormat() { Trimming = StringTrimming.Character });            //print on front                        g.DrawString(PrintInfo.AlphaArg1, new Font("Verdana", 9, System.Drawing.FontStyle.Bold), SystemBrushes.ControlText, X, Y);            e.HasMorePages = false;        }

Please Register or Login to post a reply

1 Replies

S Stephen Troup

I bit late but this might point you in the right direction.

You'll will need to look into the new Link OS SDK for the ZC range of printers to allow you to perform magnetic encoding as I don't believe the method your using will work with any of the current range of printers. I may be wrong but I've not used that method since the old Zebra P430i

If you're using visual studio you can get a Nuget package by looking for 'Zebra.Printer.Card.SDK' I'd still download a copy as the package hasn't updated yet and the SDK on the Zebra site is slightly newer plus you'll get some demo code and the manuals. You'll also need to use using at minimum Visual Studio 2015  as the SDK is now based on .Net 4.7 so no XP, Vista or Server 2008 support.

You've got two methods of encoding, with or without print. If you want to keep your current printing system using the spooler then I'd suggest you use the MagEncode function that's building to the Zebra.Sdk.Card.Printer.ZebraPrinterZmotif class. But you'll need to make sure that the printdocument has the already in printer option set as you'll need to leave the card in the 'hold position' or 'internal'.

It's not a straight forward process I had the benefit of using the ZMotif system for the ZXP 7 - 9 printers so most of my code was already in place and I just needed to switch to the new sdk so I had it working in an afternoon.

Put it this way the two lines that we used to use for mag encoding will now have to be a few hundred.

CONTACT
Can’t find what you’re looking for?