public
void PointOfSaleItemsEAN13(string txtBox1)
{
BarcodeEngine.Startup(BarcodeMajorTypeFlags.Barcodes1d);
RasterCodecs.Startup();
codecs = new RasterCodecs();
codecs.ThrowExceptionsOnInvalidImages = true;
try
{
image = codecs.Load(@"D:\LeadTool\LeadTools\Images\sample1.tif");
// Initialize linear barcodes
BarcodeEngine.Startup(BarcodeMajorTypeFlags.Barcodes1d);
barEngine = new BarcodeEngine();
BarcodeData data = new BarcodeData();
System.Drawing.Rectangle rc = new Rectangle(50, 50, 300, 250);
data.Unit = BarcodeUnit.ScanlinesPerPixels;
data.Location = rc;
data.SearchType = BarcodeSearchTypeFlags.Barcode1dEan13;
string[] barcodeText;
barcodeText = new string[1];
barcodeText[0] = strCompanyPrefix+txtBox1;
data.Data = BarcodeData.ConvertFromStringArray(barcodeText);
BarcodeColor barColor = new BarcodeColor();
barColor.BarColor = Color.Black;
barColor.SpaceColor = Color.White;
Barcode1d bar1d = new Barcode1d();
bar1d.Direction = BarcodeDirectionFlags.Horizontal;
bar1d.OutShowText = true;
bar1d.ErrorCheck = true;
bar1d.StandardFlags = Barcode1dStandardFlags.Barcode1dMsiModulo10 |
Barcode1dStandardFlags.Barcode1dFast |
Barcode1dStandardFlags.Barcode1dCode11C;
BarcodeWritePdf barPDF = new BarcodeWritePdf();
BarcodeWriteDatamatrix barDM = new BarcodeWriteDatamatrix();
barDM.Justify = BarcodeJustifyFlags.Right;
barDM.FileIdHigh = 0;
barDM.FileIdLow = 0;
barDM.GroupNumber = 0;
barDM.GroupTotal = 0;
barDM.XModule = 0;
BarcodeWriteQr barQR = new BarcodeWriteQr();
barEngine.Write(image, data, barColor, BarcodeWriteFlags.UseColors | BarcodeWriteFlags.DisableCompression, bar1d, barPDF, barDM, barQR, Rectangle.Empty);
BarcodeEngine.Shutdown();
codecs.Save(image, @"D:\LeadTool\LeadTools\Images\sample2.tif", RasterImageFormat.Tif, 24);
}
catch (BarcodeException ex)
{
MessageBox.Show(ex.Message);
}
RasterCodecs.Shutdown();
}
This is the modified code it is working fine now the line in bold was the one missing from the demo write method in the documentation.