Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save aspose-com-gists/ad90556e40dd9155172fbdcb7df1e224 to your computer and use it in GitHub Desktop.

Select an option

Save aspose-com-gists/ad90556e40dd9155172fbdcb7df1e224 to your computer and use it in GitHub Desktop.
Build Code 93 Barcode Generator in Python
# Build Code 93 Barcode Generator in Python
# Read the full guide here: https://blog.aspose.com/barcode/build-code-93-barcode-generator-in-python/
# Complete working code for generating a Code 93 barcode with Aspose.BarCode for Python via .NET
import aspose.barcode as barcode
from aspose.barcode import BarCodeGenerator, EncodeTypes, BarCodeImageFormat, Color
# Initialize the barcode generator with Code 93 symbology
generator = BarCodeGenerator(EncodeTypes.CODE_93)
# Set the data to be encoded (must be alphanumeric)
generator.code_text = "ABC-1234-XYZ"
# Optional visual customizations
generator.x_dimension = 2.0 # Width of the smallest bar (in points)
generator.bar_height = 100 # Height of the barcode (in points)
generator.fore_color = Color.black # Bar color
generator.back_color = Color.white # Background color
# Save the barcode as a PNG image
output_path = "code93_barcode.png"
generator.save(output_path, BarCodeImageFormat.PNG)
print(f"Barcode saved to {output_path}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment