Basic Steps to Create a 1D Barcode
-
Set the value you want to create:
Property Description BarcodeType Gets and sets the type of barcode to create from the BarcodeType enumeration. BarcodeValue Gets and sets the value of the barcode to be created. BarcodeData Gets and sets the current barcode value as an array of bytes used only if non-ASCII text values are needed. -
Call the
CreateBitmap
method to create a System.Drawing.Bitmap from the BarcodeXpress.writer member:Method Description CreateBitmap Creates Bitmap barcodes. Create Creates a DIB (Device Independent Bitmap). There are many additional properties within the Writer class which may be used as needed in creating barcodes. See the class overview for more information.
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");