Thanks for your work Brad. Have been using version 12 with no problems. I failed to grab the source code back then and I see it's up to v14 now. Do you still have the v12 source around that you could post or email me? I know I could use a disassembler/decompiler, but it would be nice to have the actual source with comments etc.
I've been using your library and is very great your implementation. Recently I was asked to make some reports with barcode for a company and I decided to implement your dll. The problem is that they tell me that although the barcode scanner reads the generated bar, it is in an incorrect format. They use GS1-128 Standar for their business.
So far I've read that GS1 is not a barcode per se but an implementation of Code 128 but none of the 128 options in your library generates the correct barcode. My first question is: With this current library, is posible to generate barcode with the GS1 128 specifications? If so, how can I do it? The human readable string has the following structure: (000)0000000000000(0000)000000(0000)00000000(00)00000 .the parenthesis are supposed to mark the begining of a identifier but it seems these have to be sent/encoded in an different way.
If it's not possible, have you maybe any documentation about this or do you know where I can find documentation to this GS1 specification? Thanks in advance for your help.
Edit:I found in the library code that you have the FNC1 special character but I haven't figured out how I can send that character to the generation method. Can you give me some advice? Thanks
Brad, first of all, thanks for sharing and great work.
I am implementing this lib into my POS application and I am having an issue when I go to scan the printed barcode. I have confirmed that the barcode preview is generating properly, based on a sample I have in the scanner manual (which scans fine); however, the scanner is not reading the printed barcode.
I am using a vb.net PrintDocument.PrintPage event handler to draw the encoded barcode image to the document's graphics so there is no save involved.
Maybe I've just been looking at it too long, but i cant figure out why the image seems a touch blurry and the printed barcode renders slightly different than my preview. Perhaps it's just the a printer issue? I've tried a laser printer and a zebra label printer.
Sub pd_PrintPage(sender AsObject, e As Printing.PrintPageEventArgs)
Dim g As Graphics = e.Graphics
Dim labelW, labelH, pad, barcodeH AsIntegerDim cols, rows, colSpace, rowSpace AsIntegerDim b As BarcodeLib.Barcode
Dim textFont AsNew Font("Arial", 8.0)
Dim priceFont AsNew Font("Arial", 14, FontStyle.Bold)
Dim sf AsNew StringFormat
Dim labelPos AsNew Point(0, 0)
Dim labelPaddedPos AsNew Point(0, 0)
Dim spacing AsInteger = 4' used to give a touch of space between label elements
Dim bitmX As BarcodeItem
labelW = ConvertToPixels(txtLabelWidth.Text)
labelH = ConvertToPixels(txtLabelHeight.Text)
pad = ConvertToPixels(txtLabelPadding.Text)
barcodeH = 30Integer.TryParse(txtColumns.Text, cols)
colSpace = ConvertToPixels(txtColumnSpacing.Text)
rowSpace = ConvertToPixels(txtRowSpacing.Text)
sf.Alignment = StringAlignment.Near
sf.LineAlignment = StringAlignment.Near
sf.Trimming = StringTrimming.EllipsisCharacter
b = New BarcodeLib.Barcode
b.BackColor = Color.Transparent
b.ForeColor = Color.Black
b.IncludeLabel = False
b.Alignment = BarcodeLib.AlignmentPositions.LEFT
b.ImageFormat = Drawing.Imaging.ImageFormat.Bmp
b.Height = barcodeH
b.Width = labelW - (pad * 2)
For i AsInteger = 1To rows
' makse sure we have labels to print
If _barcodeQueue.Count = 0ThenExitFor
labelPos.X = 0' restart at column 1
For c AsInteger = 1To cols
' makse sure we have labels to print
If _barcodeQueue.Count = 0ThenExitFor' get the label from the queue
bitmX = _barcodeQueue.Dequeue
' define inner edge of the label. this is the start point for the label elements
labelPaddedPos = labelPos
labelPaddedPos.X += pad
labelPaddedPos.Y += pad
' if this is a preview, draw a rectangle that represents the edge of the physical labels to be printed on.
IfDirectCast(DirectCast(sender, POS.PrintDocumentEx).PrintController, System.Windows.Forms.PrintControllerWithStatusDialog).IsPreview Then
g.DrawRectangle(Pens.LightGray, New Rectangle(labelPos, New Size(labelW, labelH)))
EndIf' apply item description to the label
Dim StringSize As Size = g.MeasureString(bitmX.ItemDescr, textFont, labelW - (pad * 2), sf).ToSize
StringSize.Width = labelW - (pad * 2)
StringSize.Height = If(StringSize.Height > 35, 28, StringSize.Height) ' max rows of text should be 2
g.DrawString(bitmX.ItemDescr, textFont, Brushes.Black, New Rectangle(labelPaddedPos, StringSize), sf)
' apply barcode to the label
labelPaddedPos.Y += StringSize.Height + spacing
g.DrawImage(b.Encode(DirectCast([Enum].Parse(GetType(BarcodeLib.TYPE), cboBarcodeType.Text), BarcodeLib.TYPE), bitmX.SKU), labelPaddedPos)
' apply item number/sku to the label
labelPaddedPos.Y += barcodeH + spacing
g.DrawString(bitmX.SKU, textFont, Brushes.Black, labelPaddedPos)
' apply sales price to the label
Dim priceSize As Size = g.MeasureString(bitmX.SalesPrice, priceFont).ToSize
labelPaddedPos.X += labelW - (pad * 2) - priceSize.Width
g.DrawString(bitmX.SalesPrice, priceFont, Brushes.Black, labelPaddedPos)
' advance to next label position X coordinate
labelPos.X += labelW + colSpace
Next' advance to next label position Y coordinate
labelPos.Y += labelH + rowSpace
NextCatch ex As Exception
MessageBoxEx.Show("An error occurred while printing the document. Click the Details button for more information.", "Print Error", MessageBoxButtons.OK, MessageBoxIcon.Error, ex)
e.Cancel = TrueFinally
e.HasMorePages = (_barcodeQueue.Count > 0)
If b IsNotNothingThen b.Dispose()
Ive had problems scanning before but it was because my app was resizing the image which causes smearing of the bars. The image needs to be created the size you want to use. Resizing images causes distortion and can cause barcode readers to fail to scan a perfectly legit barcode.
Let me know if this makes no sense ... Im finishing a long day here and my brain is fried
I'm using your barcode library for an application I'm developing. Works great!
I just had one question. When I run my ASP.NET app on my machine, it works great. I use an xslt to lay out an html page with the barcodes I have generated. I press my reset button, which does a response.redirect and resets the page. then I select new data for the barcodes.
The problem is when I move the code to the web server. I select the data and create the barcodes, then I press "Reset" and select new data. The new text displays, but the app holds on to the barcodes from the previous generation (?) Don't know if IIS is locking the barcode files or (?)
Ever seen anything like that? its apparently something with how the barcodes interact with IIS...
Are you saving the barcodes to disk before displaying them on the website? I wouldnt do that. Id have a page that generates the barcode and returns and image and use that as the image source for the image displayed. Ive done this with an example I have. http://www.bradbarnhill.com/barcodedemo/[^]
Im not sure the situation you are in but you can use the barcodelib to write to a file as it has save functionality built in. It also has the option to generate XML from the encoding which includes a field that has the image in it.
Actually the size of the font is exposed. If you want to set it you can set the LabelFont property to a font and one of the params for a new font is the size. If you want to read the size of the font you can use LabelFont.Size and it will get you the size of the currently used font on the label.
Hope this helps and its already there for your use Let me know if I can be of more help.