Basic Steps to Create a 1D Barcode
-
Set the value you want to create:
-
Call the
CreateBitmap
method to create a System.Drawing.Bitmap from the BarcodeXpress.writer member:
C# - Basic steps for barcode writing 1D barcodes using Accusoft.BarcodeXpress.NetCore
using (BarcodeXpress bx = new BarcodeXpress("."))
{
// Set Barcode Type and Value.
bx.writer.BarcodeValue = "CODE39";
bx.writer.BarcodeType = BarcodeType.Code39Barcode;
// Create a Bitmap with Barcode Xpress.
using (System.Drawing.Bitmap bitmap = bx.writer.CreateBitmap())
{
// Save the created bitmap to a local file.
bitmap.Save("testfile.bmp");
}
}
1D barcode values are generally 7-bit ASCII, except for Code 128, which permits the use of 8-bit data. If you are using values above 127, you must use the BarcodeDataAsByte
property of the Result
class instead of the BarcodeValue
property, and your data must be encoded. Also, the reader and writer must both use the same character set.
For writing 1D barcode, Code 128, using ISO-8859-15 encoding
// Register encoding provider.
System.Text.EncodingProvider provider = System.Text.CodePagesEncodingProvider.Instance;
System.Text.Encoding.RegisterProvider(provider);
// Set the required writer properties.
System.Text.Encoding iso = System.Text.Encoding.GetEncoding("ISO-8859-15");
bx.writer.BarcodeData = iso.GetBytes("€27.99");