---
Product: barcode
Platform: python
Page Type: kb
Canonical URL: https://kb.aspose.org/barcode/python/how-to-work-with-encode-options-python
Last Updated: 2026-07-09
---

# How to Configure Encode Options in Aspose.BarCode FOSS

Configure per-symbology encoding options for Code 128, Code 39, EAN-13, EAN-8, QR Code, UPC-A, and UPC-E barcodes using Aspose.BarCode FOSS for Python.

## Problem

Each barcode symbology has its own encoding rules — error correction levels for QR Code, encode modes for Code 128, check digit handling for EAN/UPC. Aspose.BarCode FOSS for Python provides a dedicated options class per symbology so you can control these parameters at generation time.

```python
import aspose_barcode_foss as barcode
from aspose_barcode_foss import QrOptions, QrErrorCorrectionLevel

bc = barcode.qr(
    "https://example.com",
    encode=QrOptions(error_correction_level=QrErrorCorrectionLevel.H),
)
svg = bc.to_svg()
```

## Prerequisites

- Python 3.12 or later
- pip package manager
- `aspose-barcode-foss` built from source

## QR Code Options

The `QrOptions` class controls QR Code encoding. Set `error_correction_level` to one of `QrErrorCorrectionLevel.L`, `M`, `Q`, or `H`. Higher levels increase redundancy at the cost of larger symbols. Use `encoding_mode` to select a specific QR data mode (`QrEncodeMode.NUMERIC`, `ALPHANUMERIC`, `BYTE`, or `KANJI`), or leave it as `AUTO` for automatic selection. The `version` property (1–40) controls symbol size, and `mask` (0–7) overrides the mask pattern.

```python
from aspose_barcode_foss import QrOptions, QrErrorCorrectionLevel, QrEncodeMode

options = QrOptions(
    error_correction_level=QrErrorCorrectionLevel.H,
    encoding_mode=QrEncodeMode.BYTE,
    version=5,
)
bc = barcode.qr("DATA", encode=options)
```

## Code 128 Options

The `Code128Options` class exposes `encode_mode` with values from `Code128EncodeMode`: `AUTO`, `CODE_A`, `CODE_B`, `CODE_C`, `CODE_AB`, `CODE_AC`, `CODE_BC`. In `AUTO` mode the encoder selects the shortest representation. Restricting to a specific subset (e.g., `CODE_C` for numeric-only data) can reduce symbol width.

```python
from aspose_barcode_foss import Code128Options, Code128EncodeMode

options = Code128Options(encode_mode=Code128EncodeMode.CODE_C)
bc = barcode.code128("123456", encode=options)
```

## Code 39 Options

The `Code39Options` class has two key properties: `full_ascii` enables Full ASCII encoding (extended character set beyond uppercase letters and digits), and `add_check_digit` appends a modulo-43 check digit to the symbol.

```python
from aspose_barcode_foss import Code39Options

options = Code39Options(full_ascii=True, add_check_digit=True)
bc = barcode.code39("Hello", encode=options)
```

## EAN and UPC Check Digit Options

`Ean13Options`, `Ean8Options`, `UpcaOptions`, and `UpceOptions` all support `allow_check_digit_input`. By default, the library computes the check digit automatically — supply only the payload digits (12 for EAN-13, 7 for EAN-8, 11 for UPC-A). Set `allow_check_digit_input=True` to pass a pre-computed check digit as part of the input.

```python
from aspose_barcode_foss import Ean13Options

# Auto-compute check digit (12 digits)
bc = barcode.ean13("590123412345")

# Pre-computed check digit (13 digits)
bc = barcode.ean13(
    "5901234123457",
    encode=Ean13Options(allow_check_digit_input=True),
)
```

## UPC-E Number System

`UpceOptions` adds a `number_system` property. UPC-E barcodes use number system "0" or "1". Set this property to control which number system prefix the encoder uses.

```python
from aspose_barcode_foss import UpceOptions

options = UpceOptions(number_system="0", allow_check_digit_input=False)
bc = barcode.upce("012345", encode=options)
```

## Options Summary

| Symbology | Options Class | Key Properties |
|-----------|--------------|----------------|
| Code 128 | `Code128Options` | `encode_mode` |
| Code 39 | `Code39Options` | `full_ascii`, `add_check_digit` |
| EAN-13 | `Ean13Options` | `allow_check_digit_input` |
| EAN-8 | `Ean8Options` | `allow_check_digit_input` |
| QR Code | `QrOptions` | `error_correction_level`, `encoding_mode`, `version`, `mask` |
| UPC-A | `UpcaOptions` | `allow_check_digit_input` |
| UPC-E | `UpceOptions` | `number_system`, `allow_check_digit_input` |

## See Also

- [How to Generate Barcodes with Aspose.BarCode FOSS](/barcode/python/how-to-work-with-barcode-generation-python/)
- [How to Render Barcodes with Aspose.BarCode FOSS](/barcode/python/how-to-render-barcode-python/)
- [Aspose.BarCode FOSS FAQ](/barcode/python/faq/)
- [Aspose.BarCode for Python — Enterprise Knowledge Base](https://kb.aspose.com/barcode/python/)