CODE 39 encodes digits, upper case letters and seven punctuation marks, one character per nine-element pattern of five bars and four spaces. Explicit start and stop characters delimit the symbol, so a scanner reads it without being told what to expect.
The format is wide. Ten characters occupy noticeably more space than the same ten in CODE 128, which is the usual reason for choosing something else.
Type Token
| Item | Value |
|---|---|
| Type token | C39 |
| Enum case | BarcodeType::C39 |
| Family | Linear |
| Standard | ANSI MH10.8M-1983, USD-3, also known as 3 of 9 |
| Class | \Com\Tecnick\Barcode\Type\Linear\CodeThreeNine |
Input
| Item | Value |
|---|---|
| Character set | 0-9, A-Z, space, -, ., $, /, +, %. Lower case input is encoded as upper case. |
| Length | 1 to 30000 characters |
| Check | none. Use C39+ for the modulo 43 check character |
| Extra parameters | none |
Examples
Digits
<?php
require_once __DIR__ . '/vendor/autoload.php';
$barcode = new \Com\Tecnick\Barcode\Barcode();
$bobj = $barcode->getBarcodeObj(
type: 'C39',
code: '0123456789',
width: -3,
height: -30,
color: 'black',
padding: [0, 0, 0, 0],
)->setBackgroundColor('white');
echo $bobj->getInlineSvgCode();
Letters and punctuation
$bobj = $barcode->getBarcodeObj(
type: 'C39',
code: 'TCPDF-2026/01',
width: -3,
height: -30,
color: 'black',
padding: [0, 0, 0, 0],
)->setBackgroundColor('white');
Errors
These payloads raise \Com\Tecnick\Barcode\Exception:
| Payload | Message |
|---|---|
abc! | Invalid character: 33 |
TCPDF* | The asterisk is reserved as the start/stop character |
See Also
- tc-lib-barcode : the library overview.
- Rendering Options : size, colour, padding.
- Output Formats : every renderer.
- CODE 39 with check character : the same symbology with a check character.
- CODE 39 Extended : the extended form, reaching the full ASCII set.
- CODE 93 : a denser replacement with the same reach.
- API reference : the generated class documentation.