Barcode Reader CLI

Macros

Macros are defined as name-value pairs, where a value replaces the name during the BarcodeReaderCLI session. This process is called macro expansion. Macros are used:

  • Specify names of input and output file/folder names
  • Select data presented in the output.

Macro format and expansion rules

In most cases, a macro is referenced by its name enclosed in curly brackets: {macro.name} Macro names are case-insensitive. General macro references format is: {namespace::macro.name?/format}

Where:

  • namespace:: - optional namespace to distinguish macros with the same name defined in multiple categories.
  • macro.name - the required name of a macro
  • ? - optional mark to expand undefined macro to an empty string. Without this mark, an undefined macro causes a runtime error.
  • |format - optional macro expansion control. Available formats:
    • #xN - duplicate macro value N times
    • #n - expands to the name of the macro
    • #v - expands to the value of the macro

Examples:

{tab|#x3} expands to 3 tab characters

{dob?|#n is #v} expands to a string dob is user_date_of_birth , if the current barcode contains driver's license data; otherwise, it expands to an empty string

{path.temp}{path.sep}MyOutput.xmlexpands to a MyOutput.xml file path located in a temporary folder, e.g./tmp/MyOutput.xml

{bc::page} expands to the page number in a file, where a barcode is located

Macro categories

Session macros

The Session macros remain constant in the course of the BarcodeReaderCLI session. The namespace for these macros is prg::.

Name

Value Description

path.tmp

System temporary folder path (without terminating path separator}

path.sep

Path separator character: \ on Windows, / on Linux

host

Host computer name

app.filename

BarcodeReaderCLI file name

app.version

BarcodeReaderCLI version

start.date

Session start date. Format: YYYY-MM-DD

start.time

Session start time. Format: hh:mm:ss

nl

New line character

cr

Carriage return character

eol

Carriage return + New line characters

tab

Tab character

bom

UTF-8 byte-order mark (BOM)

Environment variables

Selected environmental variables are converted to a macro.  The namespace for these macros is env::.

User macros

The User macros are defined using -d="macro.name=macro.value" option on a command line or in the configuration file. The namespace for these macros is user::. The value of user macros referenced in filename options can reference other user macros (Recursive expansion.)

Source macros

The Source macros are associated with the currently processed source. The namespace for these macros is source::.

Name

Value Description

path

Source path specified on a command line

type

Source type: file, folder, url

files

Number of files found in the source

bc.count

Total number of found barcodes

File macros

The File macros are associated with the currently processed image file. The namespace for these macros is file::.

Name

Value Description

path

Image file path

filename

Filename section of path

basename

Filename without extension

ext

The extension portion of the filename

folder

Path to a folder containing the image file

pages

Number of pages in a file

format

Image file format

size

Size of image file

bc.count

Total number of found barcodes

Page macros

The Page macros are associated with the currently processed image page. The namespace for these macros is page::.

Name

Value Description

page

Page number (1-based)

bpp

Bits-per-pixel

width

Page width in pixels

height

Page height in pixels

hdpi

Horizontal DPI

vdpi

Vertical DPI

compr

Page compression

path

Path to the image file containing this page

bc.count

Total number of found barcodes

Barcode macros

The Barcode macros are associated with the currently processed barcode. The namespace for these macros is bc::.

Name

Value Description

ind

Barcode index on a page

text

Barcode text value as UTF-8 string

data

Barcode value as a byte array encoded as base-64 string

length

Barcode value length

type

Barcode type

rotation

Barcode rotation

encoding

The encoding used to convert barcode data to UTF-8 text

tbr

TBR code used to read this barcode (not present if code was not set)

path

Image file path

abspath

Image file absolute path

page

Page number (1-based)

mod

Barcode module size in pixels

skew

Barcode skew

rectangle.left

The left coordinate of the encompassing rectangle

rectangle.top

The top coordinate of the encompassing rectangle

rectangle.right

The right coordinate of the encompassing rectangle

rectangle.bottom

The bottom coordinate of the encompassing rectangle

corners.tl.x

X coordinate of the top left corner

corners.tl.y

Y coordinate of the top left corner

corners.tr.x

X coordinate of the top right corner

corners.tr.y

Y coordinate of the top right corner

corners.bl.x

X coordinate of the bottom left corner

corners.bl.y

Y coordinate of the bottom left corner

corners.br.x

X coordinate of the bottom right corner

corners.br.y

Y coordinate of the bottom right corner

Driver's License macros

The Driver's License macros are associated with the currently processed barcode; it contains driver's license or ID card data. The namespace for these macros is dl::.

Name

Value Description

last

Cardholder family name

first

Cardholder first name

middle

Cardholder middle name

dob

Cardholder's date of birth

eyes

Cardholder eyes color

hair

Cardholder hair color

sex

Cardholder sex

height

Cardholder height in ft. and inch

weight

Cardholder weight in pounds

street

Cardholder street address

city

Cardholder city

state

Cardholder state or province

postal

Cardholder ZIP or postal code

id

Card ID number

issued

Card issue date

expires

Card expiration date