How to print customized barcode labels - c#

I have a windows application which is responsible for printing customized barcode labels roll based on user's needs like specifying the texts, dimensions and size.
The user will use Zepra and TSC barcode printers, I just need to know how to let the user choose determine the size of label and the space between labels and also the all margins (top, right, bottom and left).
I need a code-snippet does that in C# and the final result to be like this.
So, any ideas?

For Zebra part:
Here is an example how to send ZPL commands into printer:
https://km.zebra.com/kb/index?page=content&id=SA301&cat=ZISV_PL_ZPL&actp=LIST
Here you can find pdf document from ZPL commands which are send to printer. Build a suitable set of codes which will produce the label and barcode that you need:
https://www.zebra.com/content/dam/zebra/manuals/en-us/software/zpl-zbi2-pm-en.pdf
Happy Coding!

Related

C# POS receipt printing issue while print commands directly to the printer, bypassing the driver

As per suggestion and provided link by #HansPassant and #Juan from (C# POS receipt printing issue), i have made the changes in code and now writing the print commands directly to the printer, bypassing the driver (using RawPrinterHelper class). But still there is an issue with the POS printer receipt. It is not taking full width to print the row though the text is not cutting now and it is showing as full text (Screenshot attached)
But as you can see in screenshot, there are enough space left in between the right side border (Marked black) and where the text ends. If text is large string then it breaks into new line but not printing to the right side.The receipt is printing with max width which is up-to the end of dotted line.Rest right side part is blank.
Also, Can you tell me how to print Rupee Symbol before the price or amount while writing the print commands directly to the printer. Earlier when i was using the printer driver for a POS printer, there in c# code i was writing as following:
CultureInfo ci = new CultureInfo("hi-IN"); String.Format(ci, "{0:c}",ProductPrice);
But this is not working with print commands directly to the printer. It prints as "?" as you can see just before the price of each item in attached screenshot.
Thanks in advance.

Print PDF and Custom Label Size

I am generating PDF document using iTextSharp (winforms), now i need to print this generated PDF document using a Label Printer.
I have multiple Printers installed on my machine, so with VB.net I need to Select a certain Thermal printer.
Once the Printer is Selected I need to Specify Shipping Label Size (width & height).
So Once Label Printer is selected and I specified custom Label dimensions, I would like the label to be printed without any user action (Like skip the Confitm box to print).
I dont need the full code, I just need someone to put me into right direction.
Thanks
You can use the PrintDocument object. Use the Print method, and do the actual printing in the PrintPage handler. To do this, you can output to the graphics object of the parameter PrintPageEventArgs in your PrintPage handler.

Using window.print() to grouping the paper

I am using asp.net. I want to group the output paper from printer printer.
Normaly I use windows.print().
But I don't know how to control the output paper on output paper tray. grouping / shift paper
As you can see on image that the the paper is group from page 1-20, and the printer make a shift to grouping page 20-45.
46-50 in black position
51-80 in blue position ...etc.
So when I took all paper, it easy for me to separate page, because it already done by the printer.

How to print a table of generated images in C#

I need to print a set of generated images in a table like structure with headings. These heading and images are never displayed on the screen. The images are generate QR codes for a series of URLS so they can easier be read in by a scanner. There need to be a header on each column and a text id field on each row but apart from that the rows would be 4-6 columns of QR codes (2d barcode).
I have found samples for printing images and samples for printing text and even a sample to print a datagrid shown on the screen but nothing for printing text and images in a table like structure. Could anyone help me out with a basic example. The table is expected to go over multiple pages vertically so I would also need to put the heading row on each page.
Even pointing me in the right direction would be useful.
This is for a windows application where I want to have code kick off a print job with no user interaction. Using dotnet 4.0.
See my method for creating and printing FixedDocument here including source code. This method will easily allow you to generate aligned tables with images and text and save them as XPS or print them to a printer.

print on dot matrix printer in .net

anyone can please tell me the code how to print documents on dot matrix printer in C# windows application.
You can print to dot matrix "graphically", which is built-in in Windows, albeit slower.
But if you only want to print pure text with simple formattings, you need to send escape commands to your dot matrix printer, which is faster than graphical printing. Different printers has different escape commands.
Here are typical escape commands(for epson): http://www.printfil.com/manualen/c5.htm
This might help: https://web.archive.org/web/20051212193242/http://sacpcug.org:80/archives/0306/prc0603.html
What I do in VB6 then was to print to Generic / Text Only printer, you open the PRN or LPT1 as a file handle, then print escape commands on the file handle, all escape commands will be redirected to whatever printer is attached to LPT1 or PRN. You can do the same thing with C#, just open the PRN or LPT1 as a file, then print to it.
To add Generic / Text Only printer, Control Panel > Printers > Add Printer. On manufacturer, select Generic, then on printers, select Generic / Text only.
You can do the same (printing on Generic / Text Only) for Zebra printers which have their own escape commands for printing bar codes, which is faster than letting Windows print to it graphically.
When you print to an inkjet or laser printer, you generally do not use built-in fonts of the printer. You use Windows fonts. What happens is that the printer driver either builds an image of pixels (including the text) and sends it to the printer, or sends commands designed to draw lines, spline curves, and other shapes to the printer, with fonts expressed as lines and splines (outlines).
When you print to an older dot matrix printer, you can do it that way, but it’s slow. Each line of text has to be “built” from pixels, and often the lines of text do not match up with the passes of the print head (especially for fonts much larger or smaller than 12-point).
The old way of using these printers, the way they were intended, was to send the actual ASCII codes of the text to the printer. Send the number 65 (decimal), and you get a capital (upper-case) “A” for instance. The number 49 (decimal) would print the digit “1” while the number 32 would be a blank space, 33 an exclamation point (“!”), and so on. One byte = one character. The dot-matrix printer had its own built-in font, and would look the ASCII code up in its font ROM, and from there determine the exact timings of which print wires would have to strike the page exactly when to produce those letters.
By using ESCape codes, you could specify such effects as pseudo-boldfaced (basically striking the letter twice, with the second copy shifted to the right by only one dot width), double-wide (striking each column of wires twice in a row for each one time that it would normally be struck, thus doubling the width of the letter), underline (striking the bottom print wire throughout regardless of whether the letter shape calls for it at that point or not), and so on.
The printer’s own ROM handled all of these mechanical details about print wires and such. All your program had to supply is the actual ASCII codes of the text (including control codes such as the number 13 [Carriage Return aka CR] to return the print head to the left margin [or, for a bidirectional printer, prepare to print the next line in the reverse order of the previous line], usually followed by the number 10 [Line Feed aka LF] to roll the paper up one line to prepare for printing the next line).
If you wanted to print in fancy fonts that the printer didn’t have, or print graphics, you had to use an ESCape code to set the printer into “graphics mode” in which you basically sent bytes whose bits would specify to fire the individual wires of the printhead under direct program control, rather than looking up character shapes in the printer’s Font ROM. When you print normally from Windows using a printer-specific driver, this is usually what happens.
For daisy-wheel or other fixed-character printers (e.g. IBM Selectric type-ball mechanisms), the ASCII code would spin the wheel or ball to the proper position and then strike the ribbon and thus print the letter on the page, or send the right hammer up to hit the ribbon and thus the page (TeleType or old typewriter mechanism). It was not possible to do pixel graphics with these except by printing repeated periods and micro-advancing the print head and paper the width/height of a period instead of a character / row of text, respectively (which would generally wear out the period character of the daisy-wheel or ball really quickly, so many of them had metal-reinforced periods for that very reason).
How is this different from printing on inkjet or laser printer?
MSDN: Printing Overview
Preview and Print from Your Windows Forms App with the .NET Printing Namespace
Whilst it wasn't in C#, I have written Access reports that used the native fonts of an Epson printer. It was a few year ago - using Windows XP - but when the printer was selected as the default it was possible to choose the "native" fonts of the printer via the font chooser.
It was pretty neat - I could use any font I liked for the headings, which were slow to print. Then I could select the native printer font for the detail rows, which were fast. Doing it that way I had to be careful that all the "native" font detail stauff had exactly the same vertical alignment, otherwise it became slow again.

Categories