Reputation: 46
For generating Barcode in asp.net c#, Bitmap object is used that saved the image in jpeg (also checked changing image extension gif and dpi). But the problem is when we print the barcode, barcode quality is not good(it shows the fade print). Although printer "Zebra GK420" quality is good. I did some R&D on the google and used some demo dlls for barcode but barcode quality problem persists. Here is the code snippet and print output document;
Bitmap objBmpImage = new Bitmap(192, 96);
Font CR10BP = new Font("Courier New", 10, FontStyle.Bold, GraphicsUnit.Pixel);
Font TR10NP = new Font("Times New Roman", 10, FontStyle.Regular, GraphicsUnit.Pixel);
Font ID12NP = new Font("IDAutomationHC39M", 12, FontStyle.Regular, GraphicsUnit.Point);
Graphics objGraphics = Graphics.FromImage(objBmpImage);
objGraphics.Clear(Color.White);
objGraphics.DrawString(line1, TR10NP, new SolidBrush(Color.Black), 10, 2);
objGraphics.DrawString(line2, TR10NP, new SolidBrush(Color.Black), 10, 12);
objGraphics.DrawString(line3, TR10NP, new SolidBrush(Color.Black), 10, 22);
objGraphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixel;
objGraphics.DrawString(line4, ID12NP, new SolidBrush(Color.Black), 10, 36);
objGraphics.Flush();
return objBmpImage;
Upvotes: 1
Views: 976
Reputation: 38087
When trying to print barcodes from Zebra printers, you are better off using ZPL to tell it the information about the barcode and having it rendered on the printer. This is the ZPL guide (only opens in IE for me) for a 420d printer. Read the guide about the text you send to the printer to get it working. You can send a text file from the command line to test the printer using standard print commands, so you don't have to continuously recompile as you are learning the language.
Since it looks like you are using a 3of9 font, you will probably use ^B3, which is the 3 of 9 command for ZPL. Something as simple as this command (an example from the PDF), will render a barcode:
^XA
^FO100,100^BY3
^B3N,N,100,Y,N
^FD123ABC^FS
^XZ
Upvotes: 1