Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

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

Select an option

Save aspose-com-gists/db0b353d59bf8b35964ca105c151cc64 to your computer and use it in GitHub Desktop.
Generate MaxiCode Barcode in Python
# Generate MaxiCode Barcode in Python
# Read the full guide here: https://blog.aspose.com/barcode/generate-maxicode-barcode-in-python/
# Complete working code to generate a MaxiCode barcode in Python
import asposebarcode as barcode
from asposebarcode import BarcodeGenerator, EncodeTypes, MaxiCodeEncodeMode, BarCodeImageFormat
def generate_maxicode(data: str, output_path: str):
# Initialize the generator with MaxiCode type and the data string
generator = BarcodeGenerator(EncodeTypes.MAXICODE, data)
# Set MaxiCode mode (choose the appropriate mode for your use case)
generator.parameters.maxicode_encode_mode = MaxiCodeEncodeMode.MODE_2
# Optional: adjust image resolution for sharper output
generator.parameters.resolution = 300 # DPI
# Save the barcode as PNG
generator.save(output_path, BarCodeImageFormat.PNG)
if __name__ == "__main__":
sample_data = "0123456789"
output_file = "maxicode.png"
generate_maxicode(sample_data, output_file)
print(f"MaxiCode barcode saved to {output_file}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment