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!
Related
I have a chart for windows phone 7.1. However the display name on the X-axis is too long and causing a overlapping to one another. Example of it:
How can I solve this ? As I need to display 7 more columns of hawker name. Removing the series at the side will only help a little. Guide on this thanks !
Let me give you some practical advice since I have been down this road before:
1) Have a limit to the max chars in header and show ... after that
2) If someone from marketing argues about that, show them that it looks ugly in every program including Excel
3) Try using new lines to fit things better
4) Reduce font size
The algorithm should try to play around with new lines and font sizes to get a best fit and if the text is too large trim the end of it.
If someone from marketing/management argues about that, show them that it looks ugly in every program including Excel
//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.
I have a treeview that contains icons. The icons are ugly. and by ugly i mean low quality. and by low quality i mean something i would expect to see from a dos program
i would hope there would be a way to improve the image quality of the icons, but after looking around on microsoft's development site, I have yet to find a solution.
to be honest, at this point i don't even know what to look for. 'image quality' is very too broad of a phrase to search for (i've gotten very random results from google searches).
i am using an ImageList to store these icons in the TreeView. there really isnt much code to show that would be of use here - at least i dont think so.
sorry for the boring question.
Is this what you're looking for?
http://msdn.microsoft.com/en-us/library/system.windows.forms.imagelist.colordepth.aspx
The default value is set to 8-bit, so changing this property of your list will probably help. Essentially, just add the following line to your code:
imagelist.ColorDepth = ColorDepth.Depth32Bit;
It can be improved. What you need to do is to open it in photoshop or gimp and resample it at 3 times it size. Then resample it at 600 dpi and resize it down to 8 x 10.
Notice, that I specified to resize and not down size. You click on the pic and the corners have a handle for you to click on and size it down to the appropraite size. This way, the pixels are closer together.
Then, you use a very soft blur, I mean really soft. The secret is when it is printed. We print at 600 to 1200 dpi which is what will enhance the picture and that is what a printer has to keep in mind. When you print on glossy paper at 600 dpi, the pic comes out really nice and sharp.
I wanted to show some mathematical expressions in a winforms textbox. So I thought the "Cambria Math" font would be a good choice but the text looked strange due the high top and bottom margin of the font. First I thought I made a mistake but according to this question, it's the correct behavior of the font.
Why does Cambria Math have these big margin values and how can I display my string correctly in the textbox like Word 2010?
(Note that I know only a little bit about typography ;)
Edit: I had to make the textbox that tall otherwise the caret would be invisible. The font size of the textbox is set to 8.25pt
Cambria Math uses Microsoft's mathematical OpenType extensions.
Word 2007 and later understand these and display the text with reasonable spacing.
However, notepad and Word 2000 display the text with enormous spacing, just like winforms. I guess the font has this much space by default because some characters (like U+2320, top half integral) are much larger than the alphanumerics.
If you use Cambria Math with a font engine (such as the one used by winforms) that doesn't understand the math extensions, you're going to get the big spacing.
If you're displaying simple expressions you might as well use Cambria.
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.