Code 128 Barcode Generator in Python.

Barcodes are an integral part of businesses today, from inventory management to retail transactions. Code 128 stands out as one of the most versatile and widely used barcodes. Code 128 barcodes provide a practical solution for labeling products, tracking assets, and enhancing operational efficiency. In this blog post, we will learn how to develop a 128 barcode generator in Python. So let’s begin.

The article covers the following topics:

  1. Python Code 128 Barcode Generator API
  2. Generate Code 128 Barcode in Python
  3. Generate the GS1-128 Barcode
  4. UPC-A GS1 128 Coupon in Python
  5. Customize Barcode Appearance
  6. Learning Resources

Python Code 128 Barcode Generator API

We will use Aspose.BarCode for Python to generate 128 barcodes. It is a robust, reliable, and user-friendly solution for barcode generation and recognition. It supports a wide variety of 1D and 2D barcode types.

Please download the package or install the API from PyPI using the following pip command in the console:

pip install aspose-barcode-for-python-via-net 

Generate Code 128 Barcode in Python

We can easily generate a code 128 barcode by following the steps given below:

  1. Create an instance of the BarcodeGenerator class with the EncodeTypes.CODE128 as an argument.
  2. After that, specify the text to encode.
  3. Finally, save the output using the save() method. It takes the output file path as an argument.

The following code example shows how to generate a code 128 barcode in Python.

Generate GS1-128 Barcode using Python

Generate GS1-128 Barcode using Python

Generate GS1-128 Barcode in Python

We can easily generate a GS1-128 barcode by following the steps given below:

  1. Create an instance of the BarcodeGenerator class with the EncodeTypes.GS1_CODE_128 as an argument.
  2. Specify the text to encode.
  3. After that, set the barcode size value in pixels.
  4. Finally, save the output using the save() method. It takes the output file path as an argument.

The following code example shows how to generate a GS1-128 barcode in Python.

Generate GS1-128 Barcode using Python

Generate GS1-128 Barcode using Python

Generate UPC-A GS1 128 Coupon in Python

We can also generate a barcode label with an additional GS1-128 coupon barcode placed in the same image by following the steps mentioned earlier. However, we need to set the EncodeTypes as UPCA_GS_1_CODE_128_COUPON in the first step.

The following code example shows how to generate a UPC-A GS1 Code 128 Coupon in Python.

Generate UPC-A GS1 128 Coupon in Python

Generate UPC-A GS1 128 Coupon in Python

Customize Code 128 Coupon Appearance in Python

We can also customize the appearance of the barcode by following the steps mentioned earlier. However, we need to specify additional properties before saving the image in the final step.

The following code example shows how to customize the barcode appearance of GS1 128 Coupon in Python.

Customize the colors and coupon supplement space in Python

Customize the colors and coupon supplement space in Python

Get a Free License

You can get a free temporary license to try the library without evaluation limitations.

Python Barcode Generator – Free Learning Resources

You can learn more about generating and reading barcodes and explore other features of Aspose.BarCode for Python using the resources below:

Conclusion

In this article, we learned how to develop a code 128 barcode generator in Python. By following the steps outlined in this article, you can empower your Python applications to generate GS1-128 barcodes easily in a few lines of code. In case of any ambiguity, please feel free to contact us on our free support forum.

See Also