Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

Barcode.GenerateJSON

Generates a barcode.

Component Version macOS Windows Linux Server iOS SDK
Barcode 9.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "Barcode.GenerateJSON"; JSON )   More

Parameters

Parameter Description Example
JSON The JSON block with all options. {
"symbology": "QRCode",
"Text": "Hello World",
"Scale": 4
}

Result

Returns GMImage reference or error.

Description

Generates a barcode.
All parameters come as values in JSON block and most are optional.

KeyValueExample
SymbologySymbol to use. Can be number or text name.QRCode
HeightBarcode height in X-dimensions (ignored for fixed-width barcodes)50
ScaleScale factor when printing barcode, i.e. adjusts X-dimension. Default 1. Usually 4 or bigger for printing in high resolution.1
WhitespaceWidthWidth in X-dimensions of whitespace to left & right of barcode.5
WhitespaceHeightHeight in X-dimensions of whitespace above & below the barcode.5
BorderWidthSize of border in X-dimensions.5
OutputOptionsSet various output file options as number.32+4
ForeGroundColorForeground as RGB/RGBA hexadecimal string, 6 or 8 characters."ff0000"
BackGroundColorBackground as RGB/RGBA hexadecimal string, 6 or 8 characters."0000ff"
PrimaryPrimary message data (MaxiCode, Composite) ""
Option1Symbol specific options.0
Option2Symbol specific options.0
Option3Symbol specific options.0
ShowTextShow (1) or hide (0) Human Readable Text. Default 1.1
InputModeEncoding of input data. Pass 0 for data, 1 for unicode.1
ECIExtended Channel Interpretation mode.3
DotSizeSize of dots used in dotty mode.1.25
GuardDescentHeight in X-dimensions that EAN/UPC guard bars descend. Default 5.5
TextHuman readable text, which usually consists of input data plus one more check digit."Hello World"
TransparentTransparency mode: 0: black on white, 1: black on transparent background, 2: white on black, 3: white on transparent background0
RotationRotation angle to use. Multiply of 90°.0

Possible symbologies: CODE11, C25MATRIX, C25INTER, C25IATA, C25LOGIC, C25IND, CODE39, EXCODE39, EAN8, EANX, EAN128, CODABAR, CODE128, DPLEIT, DPIDENT, CODE16K, CODE49, CODE93, FLAT, RSS14, RSSLTD, RSSEXP, TELEPEN, UPCA, UPCE, POSTNET, MSIPLESSEY, FIM, LOGMARS, PHARMA, PZN, PHARMA_TWO, PDF417, PDF417TRUNC, MAXICODE, QRCODE, CODE128B, AUSPOST, AUSREPLY, AUSROUTE, AUSREDIRECT, ISBNX, RM4SCC, DATAMATRIX, EAN14, CODABLOCKF, NVE18, JAPANPOST, KOREAPOST, RSS14STACK, RSS14STACKOMNI, RSSEXPSTACK, PLANET, MICROPDF417, ONECODE, PLESSEY, TELEPEN_NUM, ITF14, KIX, AZTEC, DAFT, MICROQR, HIBC128, HIBC39, HIBCDM, HIBCQR, HIBCPDF, HIBCMICPDF, HIBCBLOCKF, HIBCAZTEC, AZRUNE, CODE32, EANXCC, EAN128CC, RSS14CC, RSSLTDCC, RSSEXPCC, UPCACC, UPCECC, RSS14STACKCC, RSS14OMNICC, RSSEXPSTACKCC, CHANNEL, CODEONE, GRIDMATRIX, EANXCHK, UPCACHK, UPCECHK, DOTCODE, HANXIN, VIN, MAILMARK, UPNQR and ULTRA..

Please use EANX for EAN-2, EAN-5, EAN-8 and EAN-13. You may need to leave away the check digit for some barcodes. EAN-13 can be created with 12 or 13 digits, but for EAN-8, only pas 7 digits.
This function returns an image reference for our GMImage functions. There you can either work on the image or simply store it in a container. On the end please free the image with GMImage.Release function.
For the size, be aware that some types like UPC codes have fixed size depending on content.

For MicroQR barcodes, you can use ECC Level 1 to 3, where 1 is default.
Length is limited to only 35 characters minus space for ECC.

Output options can be a combination of various flags:

NameValueDescription
None0No options set.
Bind2Boundary bars above and below the symbol and between rows if stacking multiple symbols.
Box4Add a box surrounding the symbol and whitespace.
StdOut8Output to stdout.
ReaderInit16Include reader initialize sequence in barcode.
SmallText32Use small text.
BoldText64Use bold text.
CMYKColors128Use CMYK colors for Postscript output.
DottyMode256Raster in dotty mode.
GS1_GS_Separator512Use GS Separator for DataMatrix.

CodeNameNumeric ValueDescription
CODE111Code 11
C25STANDARD2Standard Code 2 of 5 (Matrix)
C25MATRIX2Legacy
C25INTER32 of 5 Interleaved
C25IATA42 of 5 IATA
C25LOGIC62 of 5 Data Logic
C25IND72 of 5 Industrial
CODE398Code 3 of 9 (Code 39)
EXCODE399Extended Code 3 of 9 (Code 39+)
EANX 13EAN (European Article Number)
EANX_CHK 14EAN + Check Digit
GS1_12816GS1-128 (UCC.EAN-128)
EAN12816Code 128 (automatic subset switching)
CODABAR 18Codabar
CODE12820Code 128
DPLEIT 21Deutsche Post Leitcode
DPIDENT 22Deutsche Post Identcode
CODE16K23Code 16k
CODE4924Code 49
CODE9325Code 93
FLAT 28Flattermarken
DBAR_OMN 29GS1 DataBar Omnidirectional
RSS1429GS1 DataBar-14
DBAR_LTD 30GS1 DataBar Limited
RSS_LTD 30GS1 DataBar Limited
DBAR_EXP 31GS1 DataBar Expanded
RSS_EXP 31Legacy
TELEPEN 32Telepen Alpha
UPCA 34UPC-A
UPCA_CHK 35UPC-A + Check Digit
UPCE 37UPC-E
UPCE_CHK 38UPC-E + Check Digit
POSTNET 40USPS (U.S. Postal Service) POSTNET
MSI_PLESSEY 47MSI Plessey
FIM 49Facing Identification Mark
LOGMARS 50LOGMARS
PHARMA 51Pharmacode One-Track
PZN 52Pharmazentralnummer
PHARMA_TWO 53Pharmacode Two-Track
CEPNET 54Brazilian CEPNet Postal Code
PDF41755PDF417
PDF417COMP56Compact PDF417 (Truncated PDF417)
PDF417TRUNC56PDF417 Truncated
MAXICODE 57MaxiCode
QRCODE 58QR Code
CODE128B60Code 128 (Subset B)
AUSPOST 63Australia Post Standard Customer
AUSREPLY 66Australia Post Reply Paid
AUSROUTE 67Australia Post Routing
AUSREDIRECT 68Australia Post Redirection
ISBNX 69ISBN (EAN-13 with verification stage)
RM4SCC70Royal Mail 4-State Customer Code (RM4SCC)
DATAMATRIX 71Data Matrix (ECC200)
EAN1472EAN-14
VIN 73Vehicle Identification Number
CODABLOCKF 74Codablock-F
NVE1875NVE-18 (SSCC-18)
JAPANPOST 76Japanese Postal Code
KOREAPOST 77Korea Post
DBAR_STK 79GS1 DataBar Stacked
RSS14STACK79GS1 DataBar-14 Stacked
DBAR_OMNSTK 80GS1 DataBar Stacked Omnidirectional
RSS14STACK_OMNI80GS1 DataBar-14 Stacked Omnidirectional
DBAR_EXPSTK 81GS1 DataBar Expanded Stacked
RSS_EXPSTACK 81GS1 DataBar Expanded Stacked
PLANET 82USPS PLANET
MICROPDF41784MicroPDF417
USPS_IMAIL 85USPS Intelligent Mail (OneCode)
ONECODE 85USPS OneCode
PLESSEY 86UK Plessey
TELEPEN_NUM 87Telepen Numeric
ITF1489ITF-14
KIX 90Dutch Post KIX Code
AZTEC 92Aztec Code
DAFT 93DAFT Code
DPD 96DPD Code
MICROQR 97Micro QR Code
HIBC_12898HIBC (Health Industry Barcode) Code 128
HIBC_3999HIBC Code 39
HIBC_DM 102HIBC Data Matrix
HIBC_QR 104HIBC QR Code
HIBC_PDF 106HIBC PDF417
HIBC_MICPDF 108HIBC MicroPDF417
HIBC_BLOCKF 110HIBC Codablock-F
HIBC_AZTEC 112HIBC Aztec Code
DOTCODE 115DotCode
HANXIN 116Han Xin (Chinese Sensible) Code
MAILMARK 121Royal Mail 4-State Mailmark
AZRUNE 128Aztec Runes
CODE32129Code 32
EANX_CC 130Composite Symbol with EAN linear component
GS1_128_CC131GS1-128 Composite
EAN128_CC131Composite Symbol with GS1-128 linear component
DBAR_OMN_CC 132GS1 DataBar Omnidirectional Composite
RSS14_CC132Composite Symbol with GS1 DataBar-14 linear component
DBAR_LTD_CC 133GS1 DataBar Limited Composite
RSS_LTD_CC 133Composite Symbol with GS1 DataBar Limited component
DBAR_EXP_CC 134GS1 DataBar Expanded Composite
RSS_EXP_CC 134Composite Symbol with GS1 DataBar Extended component
UPCA_CC 135Composite Symbol with UPC A linear component
UPCE_CC 136Composite Symbol with UPC E linear component
DBAR_STK_CC 137GS1 DataBar Stacked Composite
RSS14STACK_CC137Composite Symbol with GS1 DataBar-14 Stacked component
DBAR_OMNSTK_CC 138GS1 DataBar Stacked Omnidirectional Composite
RSS14_OMNI_CC138Composite Symbol with GS1 DataBar-14 Stacked Omnidirectional component
DBAR_EXPSTK_CC 139GS1 DataBar Expanded Stacked Composite
RSS_EXPSTACK_CC139Composite Symbol with GS1 DataBar Expanded Stacked component
CHANNEL 140Channel Code
CODEONE 141Code One
GRIDMATRIX 142Grid Matrix
UPNQR 143UPNQR (Univerzalnega Plačilnega Naloga QR)
ULTRA 144Ultracode
RMQR 145Rectangular Micro QR Code (rMQR)
BC412146IBM BC412 (SEMI T1-95)

BackGroundColor can be 00000000 to turn background into a transparent black.

Examples

Create barcode based on JSON:

Set Field [ Barcode Generation JSON::Image ; "" ]
Set Variable [ $img ; Value: MBS("Barcode.GenerateJSON"; Barcode Generation JSON::JSON) ]
If [ MBS("IsError") = 0 ]
    Set Field [ Barcode Generation JSON::Image ; MBS( "GMImage.WriteToPNGContainer"; $img; "barcode.png") ]
    Set Variable [ $r ; Value: MBS( "GMImage.Release"; $img ) ]
Else
    Show Custom Dialog [ "Failed to create barcode" ; $img ]
End If

Create barcode file:

Set Variable [ $path ; Value: "/Users/cs/test.png" ]
Set Variable [ $img ; Value: MBS( "Barcode.GenerateJSON"; "{\"Symbology\": \"QRCode\", \"Text\": \"Hello World\", \"Scale\": 4, \"BorderWidth\": 4}") ]
If [ MBS("IsError") = 0 ]
    Set Variable [ $r ; Value: MBS( "GMImage.WriteToFile"; $img; $path ) ]
    Set Variable [ $r ; Value: MBS( "GMImage.Release"; $img ) ]
End If

See also

Release notes

Example Databases

Blog Entries

This function checks for a license.

Created 5th September 2019, last changed 28th June 2023


Barcode.Generate - Barcode.GetInputMode