Click here to Skip to main content
15,921,279 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using Zen bar code .dll , to generate bar code , but as per my label , if i am passing character length more then 10 , then complete bar code not getting print also not able to scan. So need to set barcode width , so that the lining of barcode get reduced and i can print 20 character on the same length label.

What I have tried:

Zen.Barcode.Code39BarcodeDraw barcode = Zen.Barcode.BarcodeDrawFactory.Code39WithoutChecksum;

var barcodeImage1 = barcode.Draw("Here passing character", 28);
var barcodeImage2 = barcode.Draw("Here passing character", 28);

var resultImage1 = new Bitmap(barcodeImage1.Width, barcodeImage1.Height + 20); // 20 is bottom padding, adjust to your text
var resultImage2 = new Bitmap(barcodeImage2.Width, barcodeImage2.Height + 62); // 20 is bottom padding, adjust to your text

using (var graphics1 = Graphics.FromImage(resultImage1))
using (var graphics2 = Graphics.FromImage(resultImage2))
using (var font = new Font("Consolas", 7))
using (var brush = new SolidBrush(Color.Black))
using (var format = new StringFormat()
{
Alignment = StringAlignment.Center, // Also, horizontally centered text, as in your example of the expected output
LineAlignment = StringAlignment.Far
})
{
graphics1.Clear(Color.White);
ev.Graphics.DrawImage(barcodeImage1, 10, 3);
ev.Graphics.DrawString(originalNo, font, brush, resultImage1.Width / 2, resultImage1.Height, format);

graphics2.Clear(Color.White);
ev.Graphics.DrawImage(barcodeImage2, 10,48);
ev.Graphics.DrawString(InhouseNo, font, brush, resultImage2.Width / 2, resultImage2.Height, format);

}
Posted
Updated 29-Jun-19 22:41pm
Comments
Richard MacCutchan 30-Jun-19 5:37am    
If the label is not wide enough to contain the complete barcode then there is nothing that you can do in code to change it. You need to find the smallest setting that allows the printing of the barcode clearly, and use labels that are wide enough to hold that amount of data.

1 solution

The problem is probably that the area you have allocated for the barcode is not sufficient for the amount of data you are trying to supply: Code39 is not a particularly space-efficient barcode, and as you add characters to it, the width of the total barcode continues to grow. Code-39 Barcode Length Calculator - Traceability[^]
If the space you have allocated doesn't grow as well, then one of three things will happen:
1) The bar widths have to be reduced. This compromises readability, and can easily lead to completely useless barcodes.
2) The barcode becomes truncated, and not all bars are printed: this renders the barcode either unreadable, or unusable as some info is missing from the read (Code39 does not contain a "built in" checksum byte, so this can't necessarily be easily detected)
3) The barcode infringes the Quiet Zone at one or both ends, and the barcode becomes unreadable.

The only solution that will work in all cases is to increase the size of the area in which you print the barcode.
 
Share this answer
 
Comments
Shakir Ali 30-Jun-19 4:17am    
Thanks for you answer , but i can not change the width of label , I have fix dimension(50*25 mm) , As i tried Neodynamic to generate the bar code , here was the option to set the bar code width, see below .
<
BarcodeItem bcItem1 = new BarcodeItem(0, 3.5, 50, 8, BarcodeSymbology.Code128, _OriginalSerialNo);

bcItem1.BarHeight = 6;

bcItem1.BarWidth = 0.3;
>
I want to know same option how i can set barcode width in Zen barcode also , so that lining of barcode get automatically adjust , as per Code39WithoutChecksum , it's getting by default width.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900