Reputation: 65
I am experiencing a serious issue that one of my clients has to print barcodes for products when a purchase is made. I made an application with the feature that the application will automatically print barcodes in the specified size and location in A4 size barcode sheet after saved. Then the issue occurs when product quantity becomes a large quantity like above 60.
Exact exception message looks like this:
{System.Exception: EGENERATE_IMAGE-2: Image size specified not large enough to draw image. (Bar size determined to be less than 1 pixel)
at BarcodeLib.Barcode.Generate_Image() in D:\WindowsProjects\InventorySoftware\SIS_1\BarcodeLib\BarcodeLib.cs:line 559
at BarcodeLib.Barcode.Encode() in D:\WindowsProjects\InventorySoftware\SIS_1\BarcodeLib\BarcodeLib.cs:line 459
at BarcodeLib.Barcode.Encode(TYPE iType) in D:\WindowsProjects\InventorySoftware\SIS_1\BarcodeLib\BarcodeLib.cs:line 341
at BarcodeLib.Barcode.Encode(TYPE iType, String StringToEncode) in D:\WindowsProjects\InventorySoftware\SIS_1\BarcodeLib\BarcodeLib.cs:line 332
at BarcodeLib.Barcode.Encode(TYPE iType, String StringToEncode, Int32 Width, Int32 Height) in D:\WindowsProjects\InventorySoftware\SIS_1\BarcodeLib\BarcodeLib.cs:line 291
at SIS.BarcodePrintA4.barcodeGenerate() in D:\WindowsProjects\PAMCo_SYSBILL\SIS_1\SIS\Classes\General\BarcodePrintA4.cs:line 164}"
Image barcodeImage;
private void barcodeGenerate()
{
int W = 100;
int H = 15;
try
{
if (type != BarcodeLib.TYPE.UNSPECIFIED)
{
barcodeImage = b.Encode(type, Barcode, W, H);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
public Image BarcodeImage(int ProductId)
{
if (ProductId > 0)
{
PurchaseMasterDA purchaseMasterDA = new PurchaseMasterDA();
productDA productDA = new productDA();
DataTable dtbl = new DataTable();
dtbl = productDA.Product(ProductId);
CompanyName = purchaseMasterDA.CompanyName();
if (dtbl.Rows.Count >= 1)
{
ProductName = dtbl.Rows[0]["productName"].ToString();
MRP = dtbl.Rows[0]["mrp"].ToString();
WholeSaleRate = dtbl.Rows[0]["wholeSaleRate"].ToString();
Barcode = dtbl.Rows[0]["productCode"].ToString();
}
barcodeGenerate();
//ToImageAndPrint();
}
return barcodeImage;
}
barcodeImage = Bp.BarcodeImage(int.Parse(dtBarcodeDetails.Rows[iRows]["ProductID1"].ToString() == "" ? "0" : dtBarcodeDetails.Rows[iRows]["ProductID1"].ToString()));
graphics.DrawImage(barcodeImage, loc1);
Rs1 = "Rs ";
Upvotes: 1
Views: 5405
Reputation: 21
Try set a width bigger than the codebar:
public Image CodeImage {
get {
_ = barcode.Encode(barcode.EncodedType, code);
int minWidth = Math.Max(100, barcode.EncodedValue.Length);
return barcode.Encode(barcode.EncodedType, code, minWidth, 35);
}
}
Upvotes: 1
Reputation: 134
EGENERATE_IMAGE-2 exception that one of my encountered is about barcode size because of barcode data. You can try expand barcode width and height if barcode height is less from standart.
Upvotes: 1