Created
June 19, 2026 09:40
-
-
Save aspose-com-gists/db0b353d59bf8b35964ca105c151cc64 to your computer and use it in GitHub Desktop.
Generate MaxiCode Barcode in Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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