Topics   All   MacOS (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Deprecated   Guides   Examples   Videos
New in version: 10.5   11.0   11.1   11.2   11.3   11.4   11.5   12.0   12.1   12.2    Statistic    FMM    Blog  

Barcode.GenerateJSON

Generates a barcode.

Component Version macOS Windows Linux Server iOS SDK License
Barcode 9.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes Paid
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
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
ShowTextWhether to show text. Pass 0 to hide text.1
WhitespaceWidthWhitespace width.5
BorderWidthBorder width.5
OutputOptionsSet various output file options as number.0
ScaleScale factor for adjusting size of image. Usually 4 or bigger for printing in high resolution.4
Option1Symbol specific options.0
Option2Symbol specific options.0
Option3Symbol specific options.0
InputModeSet encoding 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
PrimaryPrimary message data for more complex symbols. ""
ForeGroundColorForeground (ink) colour as RGB hexadecimal string. Must be 6 characters."ff0000"
BackGroundColorBackground (paper) colour as RGB hexadecimal string. Must be 6 charaters."0000ff"

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.

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

Created 5th September 2019, last changed 24th December 2021


Barcode.Generate - Barcode.GetInputMode

Feedback: Report problem or ask question.


Start Chat