 |
 | EAN128 support A.N. Arefin | 22:49 5 Feb '10 |
|
 |
hi, First, thank you for such a library. Actually I need EAN128 type Barcode image. In that case, what is the solutions?
Thanks, Arefin
|
|
|
|
 |
|
 |
If your data is formatted according to how EAN128 requires it to be formatted then Code 128 is the same encoding. There is a post about this before. This library focuses on the encoding of the data and not so much the data formatting rules.
There are several symbologies or 'sub-symbologies' as I call them that are encoded the same but have different rules on data and how it is formatted. All you have to do is make sure you adhere to those standards and tell this library to encode your data using C128 and it will work just fine.
Let me know if this answers your question.
Thanks,Brad Barnhill
|
|
|
|
 |
 | .. dooglex | 9:37 28 Jan '10 |
|
 |
thank you
|
|
|
|
 |
 | How to display directly the bar code generated ? matgk26 | 1:49 27 Jan '10 |
|
 |
Hi,
First of all thank you so much for this great work. I'd like to generate a bar code and display it into a webpage onthego (without saving it physically on the hard drive). Is it possible ? and how ?
|
|
|
|
 |
|
 |
The library returns an IMAGE... so you can use this to display your barcode in a picturebox. I dont know how explain it any easier ... its just that simple.
Let me know if this answers your question.
Thanks,
Brad Barnhill
|
|
|
|
 |
|
 |
It seems that in ASP.Net Web Application there is no picturebox.
I am trying this but it doesn't seem to work :
protected System.Drawing.Image code_barre;
protected void Page_Load(object sender, EventArgs e) { Barcode b = new Barcode("2072009115090", BarcodeLib.TYPE.EAN13); b.IncludeLabel = true; code_barre = b.Encode(TYPE.EAN13, "2072009115090", System.Drawing.Color.Black, System.Drawing.Color.Red, 300, 300); Graphics grp = Graphics.FromImage(code_barre); grp.DrawImage(code_barre, 0, 0); }
An idea ...?
|
|
|
|
 |
|
 |
Yeah have a page (GenerateBarcode.aspx) that returns an image.
Then use <img src="GenerateBarcode.aspx?data=13412341234">
That is a shorthand version of what I would do. Let me know if that helps ya. I know that works because I have a working copy of that very idea at www.bradbarnhill.com/BarcodeDemo/
here are some snippets:
Main page:
string strImageURL = "GenerateBarcodeImage.aspx?d=" + this.txtData.Text.Trim() + "&h=" + this.txtHeight.Text.Trim() + "&w=" + this.txtWidth.Text.Trim() + "&bc=" + this.txtBackColor.Text.Trim() + "&fc=" + this.txtForeColor.Text.Trim() + "&t=" + this.cbEncodeType.SelectedValue + "&il=" + this.chkGenerateLabel.Checked.ToString() + "&if=" + this.ddlImageFormat.SelectedValue; this.BarcodeImage.ImageUrl = strImageURL; Generate the barcode in GenerateBarcode.aspx and take the results which are an image and use this:
Where barcodeImage is the image returned from the barcode library...
Response.ContentType = "image/jpeg" + strImageFormat; System.IO.MemoryStream MemStream = new System.IO.MemoryStream();
barcodeImage.Save(MemStream, ImageFormat.Jpeg); MemStream.WriteTo(Response.OutputStream);
Hope this helps. It should most definately get you started in the right direction. Dont give up its VERY simple to do, and I showed you my example of it working.
Thanks,
Brad Barnhill
|
|
|
|
 |
 | Something is wrong with type 39 extended Member 4742272 | 4:23 20 Jan '10 |
|
 |
I'm sorry, but I think I found a bug with your tyoe 39 extended implimentation.
I have a type 39 extended capable barcode reader. It reads type 39 codes from barcodelib, but not type 39 extended.
At first I thought the reader was the problem, but then I generated the same code using the Barcode Generator from Neodynamic and it generates a different barcode which scans correctly. I also noticed that the test code I was using (S10-00302) looks the same using type39 / type39 extended in Neodynamic whereas barcodelib generates codes that look very different.
Cheers,
James
|
|
|
|
 |
|
 |
So let me get this straight ... with (S10-00302)you are showing a different barcode than with your code and neodynamics code?
Can you email me a copy of the image that you are generating with either one? This would help me debug it. Plus I cant debug it tonight with my brain fried ... Ive been in clinicals for nursing school for 2 days straight while studying in between for a test I just got out of ... now Im sitting in lecture ... there is no telling what kind of code I would write 
Get me an example and Ill make sure to look at it.
Thanks for letting me know of a potential bug ... keeps me excited about fixing something.
Brad Barnhill
|
|
|
|
 |
|
 |
My test application that reads barcodes (bytescout reader) doesnt read code 39 extended. It reads code 39 just not the extended symbology.
Let me know if you know of a way to test this without me printing a thousand sheets of paper while testing.
Thanks for your help and I am truely dedicated to fixing this issue. I think someone before had mentioned an issue with Code 39 extended but I cant remember what that was. I wonder if that affected this.
Lets keep this conversation going so we can make sure this gets fixed.
Thanks for your help again,
Brad Barnhill
|
|
|
|
 |
|
 |
The problem is that the generated Code 39 Extended image has no start or stop characters. I think the bug is in the InsertExtendedCharsIfNeeded() function (method, whatever). That function operates on the Raw_Data member, which has start/stop characters only if the user explicitly includes '*' as the first and last characters. It appears that the function intended to operate on the FormattedData argument rather than the Raw_Data member. For the short term, James, you could add those characters yourself (i.e. *S10-00302*) and I believe your images will be OK. For a true fix, I would iron out the inner workings of the InsertExtendedCharsIfNeeded() function. I hope this helps.
|
|
|
|
 |
|
 |
pomerleau where ya been? Havent seen you post on here in a while but none the less ... WELCOME BACK!!!
Thanks for pointing out the bug. Ill take a look at this and probably realize another stupid mistake on my part.
It may be a few days before I can get to it as Im playing catch-up on my paperwork for school.
Thanks again,
Brad Barnhill
|
|
|
|
 |
|
 |
Found that bug ... fix will be released in version 1.0.0.10 ... Pomp did find the right place for the fix by the way.
Thanks to both of you, another bug is fixed.
Brad Barnhill
|
|
|
|
 |
 | Barcode width compress awadhesh4772 | 22:25 18 Jan '10 |
|
 |
Hi Brad,
I am very glad to use your barcode library.. it is really very helpfull.
I just wanted to know how can compress barcode width. E.g. I wanted to print 12 digit no on 4.0cm wider label with code 128B, which is going out now.
Thanks for your reply. Awadhesh
|
|
|
|
 |
|
 |
You dont have the option of setting width via (cm or inches) but you do have the option to adjust it via pixel width. If you find a pixel width that works stick with that width and it should work just fine.
Let me know if that helps.
Brad Barnhill
|
|
|
|
 |
|
 |
Thanks for your reply. I already used 170 x 30 pixel to determine barcode dimesion for 12 digit numbers. pls refere below script line.
e.Graphics.DrawImage(BarcodeLib.Barcode.DoEncode(barType(cbSymbology.SelectedItem), "A000000012 1", False, 170, 30)
but I want to print barcode in compressed mode instead of normal mode.
If i m reduce pixel less than 170, I got error "Image size specified not large enough to draw barcode".
Hope you understand my requirement. seek your help.
regards, awadhesh
|
|
|
|
 |
|
 |
It's not possible to reduce the bitmap width further. The barcode you want to draw encodes to a certain number of bars and spaces. If you specify a bar-width of 1 pixel (the smallest value you can use) and if your barcode comes to 170 bars, you won't be able to fit it in a bitmap that is smaller than 170 pixels. The only way you can use a smaller bitmap is therefore to use fewer bars, which means encoding less data - which is not much use to you.
Since you want to print a barcode that is in real-world measurements (4cm, you say) you can set the DPI of the bitmap before creating a Graphics object for it. This sets the number of pixels-per-inch for your barcode. It will still be 170 pixels, but will print 4cm.
If you require a 4cm barcode, you convert 4cm to inches and divide your bitmap width (in pixels) by the result. This tells you how many pixels you will need to squeeze into 1 inch. So you can then set the DPI of your bitmap accordingly.
For example, in C#:
<pre>// 1cm = 0.393700787 inches float cm = 4f; float pixelwidth = 170f; float dpi = (float)( (decimal)( pixelwidth / ( cm * 0.393700787f ) );
Bitmap canvas = new Bitmap( pixelwidth, 30 ); canvas.SetResolution( dpi, dpi );
using ( Graphics surface = Graphics.FromImage( canvas ) ) { surface.DrawImage(BarcodeLib.Barcode.DoEncode(barType(cbSymbology.SelectedItem), "A000000012 1", False, pixelwidth, 30), etc... // etc. }</pre>
(I don't know if that code will compile directly; I just typed it in this reply box, but it should give you a fair idea)
|
|
|
|
 |
|
 |
Awad ... fear is correct ... if you have a barcodes data and you feed it to the library it automatically determines what width to draw the bars and still get them into the given size image. If it is smaller than 1px wide for each bar then it throws that error. Its a battle of give and take ... if you want more data encoded you will have to have more space to draw it, even with 1px wide bars. So at 170px wide and that amount of data you will either have to make it wider than 170 or shorten your data somehow. Unless you can draw in smaller than 1px wide lines, which im pretty sure you cant, someone correct me if I am wrong. Awad let me know if this helps explain it, even though it doesnt solve you delimia. Let me know if we need to help you some more or whatever. I aim to please and will help, just ask fear (which is a godsend to this library in answering questions).
Hum this gives me an idea fearmint ... what if i incorporated a resize function into the library with this code? I tried this once before and the barcodes were flaky at best due to the compression of the images and what it does to the bars. They look good when printed just they wont scan ...
Have you tested this much?
Please let me know ... Im interested in re-adding this again if it works.
Thanks,
Brad Barnhill
|
|
|
|
 |
|
 |
Brad, I have same problem too. 4cm and the code must fit in it...
I have tried to convert drawing to bmp, i could change size whatever i want but barcode scaner could not scan it. because when i resize it form orginal size, bitmap was deforming (or bitmap quility maybe poor). If you can solve this, let me know.
thans for this library.
Judasis
|
|
|
|
 |
|
 |
Ok let me explain this one more time:
The smallest you can draw a line in C# is 1 pixel wide. When you specify a size of 300 pixels or whatever then the barcode you want to draw in that space must fit in that space with a minimum bar width of 1 pixel or it will throw an error. This is NOT a bug, it happens when you try to encode an amount of data that it determines can not fit in that space. If you resize the image once its drawn it will cause blurring on the edges. This was how the first version of the library did sizing which was quickly removed due to how many problems it caused.
So in short. When you specify a type of barcode, and a set of data to encode. That data is then used to calculate the maximum bar width that can be used to draw that barcode in that space available. This is then considered the bar width. If that width is less than 1 (pixel) then it will throw an error, because it can not draw a bar less than 1 pixel wide. This is on purpose, this is not a bug. You are trying to fit a barcode in a space that it can NOT be drawn.
Let me know if that makes any sense. Fearmint feel free to chime in here. I believe I explained it but I have been up for 48 hours straight and no end in sight yet ... so ... It may be a little rough around the edges 
Thanks,
Brad Barnhill
|
|
|
|
 |
|
 |
I'm getting a bit tired of answering this same question myself! 
ok...
judasizm, you say that you want a 4cm wide barcode. However, you are getting a bitmap whose dimensions are pixels, not centimetres. So what is 4cm in pixels? How many pixels fit into a centimetre? The property that determines this is the DPI (dots-per-inch) - see my reply four posts up in this very thread.
The barcode you generate is only larger than 4cm because the default DPI for a bitmap is something like 96. A barcode that has 170 bars/spaces in it (for example), drawn at 1 pixel per bar/space, at 96dpi comes to about 4.498cm (not considering quiet zones or space for bearer bars, etc); clearly larger than 4cm.
You are saying that your generated barcode bitmap doesn't fit in 4cm, but it's a bitmap whose width and height are pixels, not cm. You need to calculate the DPI that enables your pixel width to fit into 4cm (which I explained earlier in this thread, and other threads), then create a bitmap and set its DPI to this value, then draw your barcode on it (either by altering brad's library to draw the bars directly or by drawing the bitmap that the library creates onto another bitmap which has the correct DPI).
(You do need to set DPI *before* creating a Graphics object to do the drawing)
Brad, I think the problem that people have is that barcodes are really only any use when printed and people want to print them at a specific size (in inches, centimetres, millimetres, etc) not pixels - pixels don't mean anything in printing. Your library only allows setting the size of a barcode in pixels. You might fancy creating a simple class or struct of metrics properties that can be passed to the barcode class to provide the real-world-unit widths and heights of the various parts of the barcode. (Maybe also a property specifying what units those sizes are measured in.) Then you can create a bitmap that exactly fits your barcode and have the dpi set to something that will fit those pixels into the required real-world-unit size.
ie: public class CanvasMetrics { AUnitsOfMeasurementEnum Units; float BarcodeWidth; float BarcodeHeight; float LabelHeight; float QuietZoneWidth; float BearerBarTopThickness; float BearerBarBottomThickness; float BearerBarLeftThickness; float BearerBarRightThickness; // etc }
(Of course, if you go down this route you'll eventually get to the problem of how to draw the text label so it fits in the specified inch width, but that's a whole other story )
|
|
|
|
 |
|
 |
Yeah I plan on adding the ability to specify a measurement in real world dimensions (cm, in... etc) I just have to find time to add it.
This is a great idea but I dont know that Ill go to the length of creating quiet zone space, and bearer bar thickness that they can set ... this just opens a WHOLE new can of worms.
Brad Barnhill
|
|
|
|
 |
|
 |
I like the common sense that fearmint is adding here, describing that there is a minimum amount of pixels below which one cannot go to represent a bar code. In general this number occurs when 1 physical pixel is equal to 1 module in a symbology. Think of a module as the fundamental unit in a bar code where the narrowest element is defined as one module wide (so a Code 128 character is 11 modules wide, and a Code 39 character whose wide to narrow ratio is 'N' is 3N+6 modules wide not counting the intercharacter gap, etc.). Printers have a similar fundamental unit - their dot size, where a dot is the smallest mark the printer can make.
The correct way to print a bar code is to have each module be some integer number of printer dots (and greater than 1 for better results). Printers don't print half-dots, otherwise -that- would be their dot size. Trying to print a fractional dot is like rescaling an image from 170 to 150 pixels. At some point information has to get thrown away. In a bar code, discarding that kind of information often leaves the symbol unreadable, no matter how pretty it may look to the eye (oh, to have a nickel for every user who said, "The code looks great, it just doesn't scan...").
Please consider all this when thinking about the strategy posted above about setting a bitmap's DPI. It's not quite enough to simply set a bitmap's resolution to allow it's pixels to fit in a given physical width. If that resolution is greater than what the printer supports, then you still have the same problem of rescaling, just shifted to the printer instead of the screen image.
The usual strategy other print software has taken is not too different that what fearmint is driving toward. The low level symbology functions deal with plain pixels (here it would be Brad's library) and some kind of user interface deals with the physical world (here it would be the modified application, or maybe a wrapper for the library). Usually the user specifies the "X dimension" (the physical width of a module) and determines if the resulting symbol has an acceptable size. Good software limits X dimension selection only to what's possible on a given printer or at a given resolution. So far this is all possible within this implementation.
Quiet zones are a separate topic...
|
|
|
|
 |
|
 |
If I end up implementing the measurement specification of size instead of just pixels then I may consider quiet zone specification ... finding time is just really difficult right now. Ill get to it at some point. Next step is to review the new symbology that just arrived via email and try to make sure it conforms to the library. Then releasing a new version due to a few bugs getting fixed and a new symbology.
Hope you all just 'keep the faith'  (Ive slept about 4-5 hours in the last 72)
Time for some rest.
Brad Barnhill
|
|
|
|
 |
|
 |
why don't you try metafile format? i have writen similar barcode library but i used bmp as you. bmp endless way i know. i didn't say "bug". this code is greate, but there is something we may give idea to whom created this code. i don't have enough time now, to spend for this code . but i will. First of all, i'll convert your code bmp to metafile and finaly convert again to bmp. i hope it may solve resizing problem. best regards, Judasis
|
|
|
|
 |