//Please don't close this post due to subjective reasons.
I'm developing a form-filling winform application which generates a PDF file on submitting the information. The PDF file need to contain barcodes encoding some information entered by user. The user prints the PDF file and put signature on it and faxes it back to us. I need suggestions for choosing which barcode symbology to use for this applcation.
The barcode needs to satisfy the following conditions.
1)The barcode need to encode upto 120 characters
Since the barcode need to encode a lot of information, I think 2D Barcode would be better as it can store with much high information density.
2)Only upper case alphabets and numbers need to be encoded
Though most of the 2D barcodes can store more than numbers, there are some 1D barcodes such as code 39 that cannot represent all alphabets.
3)Preferable size of barcode is 1.5 inch height and 8 inch width
This is what is the most challenging requirement. I'm planning to place the barcode below the information such as account id. So it would be good if barcode takes the shape of a rectangle whose information capacity increases with its width. This requirement is suitable for 1D barcodes. Also, since 2D barcodes takes the shape of a square, a lot of space will be wasted on either side of barcode.
4)Error correcting capability
2D barcodes have better error correcting capability. Only some 1D barcodes have error correction with it. This is not an essential requirement.
5)The barcode need to be faxed from one country to another
The barcode is generated on a PDF. The PDF will be printed and then need to be faxed. So, the barcode needs to have high resolution. Otherwise, I fear that the scanner cannot decode data correctly. I'm thinking a resoltion of 200dpi is enough for the barcode image. Is there any problem to fax 2D barcodes as they need to be scanned both horizontally and verically. I have heard like fax have different resolution vertically and horizontally. Does this create any problem when scanning barcodes.
6)Easiness to program in c# to generate barcode
Atlast but not the least, I need to program this barcode generation myselfin c#. So, there should be some free library available for the same. Aspose barcode is a good one. But it is costly.
I have come across the following Barcodes. I have checked the specification of some of these types. But couldn't reach a final decision. I can't turn back once I choose a barcode and start programming.
1D: UPC/EAN/JAN, Code 39, Code 128, Interleaved 2 of 5, Codabar, Code 11, Code 93, NEC 2 of 5, Matrix 2 of 5, Trioptic Code,
Stacked 1D: PDF417, Micro PDF417, Codablock A & F, Composite Codes
2D: Data Matrix, QR Code, Micro QR Code, Aztec Code, Maxicode
I am thinking of using PDF417. Does it have any disadvantages?
I don't know all formats so I can't say which is best.
Some of the 1D barcodes you mention (UPC/EAN) support only a small number of numeric characters. I know Code 128 supports variable length alphanumeric values, so that probably is a good 1D candidate.
Some barcode readers don't support 2D barcodes, this is usually a reason to use 1D.
Of 2D you should see if there is a symbology that does not require the barcode to be a square, because that would limit your maximum size to 1.5 by 1.5 inches.
There are several websites that let you create barcodes as images - perhaps you should just create a PDF containing those and fax them to see what happens.
I don't know of any free libraries to render them with; there are also fonts out there that allow creating 1D barcodes, and you can embed these fonts into your winforms application.
EDIT: 200 dpi on 8x1.5 inches would give you 1600 dots horizontally and 300 dots vertically to work with. A code128 barcode with a bar width of 1 pixel would come out at under 1400 dots.
On the wikipedia page for QR there is an example that takes up to 174 characters that has a size of 57x57 and high error correction. If I'm not mistaking, each dot could be represented by 5x5 pixels in 200dpi.
Related
I need to enter a text to existing pdf (in top or bottom of the page) in c#.
I need to make sure that I dont overwrite any visible text or image.
Is there any way I could check an area in pdf if it contains text, image, control etc? I understand it will not be 100% accurate
You're going to need a full PDF consumer at the very least, because the only way to find out where the marks are on the page is to parse (and possibly render) the PDF.
There are complications which you haven't covered (possibly they have not occurred to you); what do you consider to be the area of the PDF file ? The MediaBox ? CropBox, TrimBox, ArtBox, BleedBox ? What if the PDF file contains, for example, a rectangular fill with white which covers the page ? What about a /Separation space called /White ? is that white (it generally gets rendered that way on the output) or not ? And yes, this is a widely used ink in the T-shirt printing industry amongst others.
To me the simplest solution would seem to be to use a tool which will give you the BoundingBox of marks on the page. I know the Ghostscript bbox device can do this, I imagine there are other tools which can do so. But note (for Ghostscript at least); if there are any marks in white (whatever the colour space), these are considered as marking the page and will be counted into the bbox.
The same tool ought to be able to give the size of the various Boxes in the PDF file (you'd need the pdf_info.ps program for Ghostscript to get this, currently). You can then quickly calculate which areas are unmarked.
But 'unmarked' isn't the same things as 'white'. If you want to not count areas which are painted in 'white' then the problem becomes greater. You really need to render the content and then look at each image sample in the output to see if its white or not, recording the maxima and minima of the x and y co-ordinates to determine the 'non-white' area of the page.
This is because there are complications like transfer functions, transparency blending, colour management, and image masking, any or all of which might cause an area which is marked with a non-white colour to be rendered white (a transparency SMask for example) or an area marked with white to be rendered non-white (eg a transfer function).
Your question is unclear because you haven't defined whether any of these issues are important to you, and how you want to treat them.
This question already has answers here:
Printing PNG images to a zebra network printer
(6 answers)
Closed 8 years ago.
I'm working on creating a HTML5 canvas based signature/drawing box. Currently we save the canvas on the server as a PNG, but can easily save the base64 string in the database. Now the question is how do we include the signature on the printed receipt.
Currently we use a ^GF field to handle printing images, but the question is what format the PNG file needs to be in for the printer. Can I simply include the Base64 encoded string? Or should I convert it to an ASCII Hex string? Or should I really be converting it into a bitmap first?
I'm not really finding any documentation on whether or not this specific printer handles PNG files, or even how to send them. The only information I've found says to send it as a B64 or Z64 bitmap, but I see references to sending a png everywhere.
The data that is you need to send isn't a PNG. You need to take the image and convert it to black and white and send the data to the printer. For example, if you have an image that is 40x50px you would take the image, and strip out the color information so you would have a total of 2000 bits of data. Then send your ZPL down like ^GFB,250,250,5,{2000 bits of data}.
I got 250 by taking 2000 bits / 8 (bits / byte) to get 250 bytes. I got 5 by dividing 40 by 8. The number of rows will be calculated automatically.
Something that I find useful when dealing with Zebra printers is to think in terms of bits. All graphics are done on a bit level.
Remember that the image you are going to send down will change size depending on the DPI of the printer. A 203 DPI printer will show my example at about .2in x .25in. On a 300 DPI printer it will show at about .13in by .16in. This is because the printer will just place raw data onto the format and the number of px is the number of dots the image will be.
Hope this help!
References:
[1] ZPL Manuel on page 208(^GF page2).
I did like to print a barcode using C#. I want the barcode to have a given height and width. I did download a free 3 of 9 barcode font and used
Font barcodeFont = new Font("Free 3 of 9", 17, FontStyle.Regular);
e.Graphics.DrawString("*"+label.Lpn+"*", barcodeFont, Brushes.Black,new RectangleF(166,235,115.16f,61));
to print it. I have two issues with this.
) for some font size barcode is
printed in two line.
) even if I
reduce the font and make it print in
one line. The barcode does not scan
well. I have to swipe it in a
perticular way to make it work.
Is there a better way to print barcode which will scan every time??
There are minimum and maximum widths for the lines and spaces of a 3of9 barcode.
Take a look at this website for more info about these measurements: http://www.adams1.com/39code.html
Take a look here at CodeProject for a decent Barcode generator. This is capable of generating different types of Barcodes including 3 of 9.
Hope this helps,
Best regards,
Tom.
Code 3 of 9 does tend to be quite a wide barcode and the only way you'll really solve your problem is by giving it more space on the page.
An alternative to this would be to either encode your data so it takes up less characters/bars or instead do a database lookup, so 1 = Bananas, 2 = Apples, 3=VeryLongWordThatDoesntFit etc.
Another alternative would be to improve the quality of the barcode scanner. It is true with barcode scanners that the more you spend the better results you get.
Does the barcode font provide recommended point sizes? A free font might not have the hinting required to insure that each bar is an integral number of pixels wide. This might be a problem especially if your printer has an odd DPI. I'm aware of one model of label printer that is 203 DPI, good luck matching your font size to pixels on that printer!
How can I get the DPI of the PDF that I am reading from my hard drive into iTextSharp?
PDF's do not necessarily use DPI in their definitions. PDF's allow the document creator to define their own user coordinate space which may or may not map to anything similar to Dots Per Inch.
Check this How to calculate the correct image size in out pdf using itextsharp ?
PDF UserUnit shall give the size of default user space units, in multiples of 1 ⁄ 72 inch.
ISO-32000-1 (section 8.3.2.3) tells us
“the default for the size of the unit in default user space (1/72
inch) is approximately the same as a point (pt), a unit widely used in
the printing industry. It is not exactly the same; there is no
universal definition of a point.”
Conceptually, user space is an infinite plane. Only a small portion of this plane corresponds to the imageable area of the output device: a rectangular region defined by the CropBox entry in the page dictionary. The region of default user space that is viewed or printed can be different for each page.
Coordinates in user space (as in any other coordinate space) may be specified as either integers or real numbers, and the unit size in default user space does not constrain positions to any arbitrary grid. The resolution of coordinates in user space is not related in any way to the resolution of pixels in device space.
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.