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

Barcode.SetOptions

Sets options for barcode creation.

Component Version macOS Windows Linux Server iOS SDK
Barcode 4.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "Barcode.SetOptions" { ; Option1; Option2; Option3 } )   More

Parameters

Parameter Description Example Flags
Option1 The first option. 1 Optional
Option2 The second option. 1 Optional
Option3 The third option. 1 Optional

Result

Returns OK.

Description

Sets options for barcode creation.
Creating a barcode will reset those options to zero for next barcode.

For QRCode:
Option1 is the ECC Level with values from 1 = low, 2 = middle, 3 = better, 4 high. Default is low.
Option2 is version code from 1 to 40. Default is 0 to auto select.
For MicroQR you can use ECC Level 1 to 3 as 4 is not supported.

For Data Matrix:
Option2 size from 1 to 30. 0 is auto. See table in zint manual pdf.
Option3 can be 100 to force square size.

e.g. below we set option3 to 100 to square, output options to 16 for reader init added and we pass some hex encoded characters in the JSON for Barcode.GenerateJSON function:
{
"Symbology":"DataMatrix",
"Scale":4,
"Option3":100,
"OutputOptions":16,
"Text":"[)>\u001e06\u001d12P4992\u001d\u001e\u0004"
}

For Code 39:
You can set Option2 to 1 to add module 43 checksum.

For MaxiCode:
Option 1 is the mode.

For PDF 417:
Option 1 is a number between 0 and 8 where the number of codewords used for check information is determined by 2^(value + 1).
Option 2 is the number of columns between 1 and 30.

See also Barcode.DrawBarcode, Barcode.WriteFile and Barcode.Generate.

Examples

Set better ECC level for QRCode:

MBS( "Barcode.SetOptions"; 3)

Set square option for data matrix:

MBS( "Barcode.SetOptions"; 0; 0; 100 )

Create QRCode with UTF-8 and size 10:

Set Field [Barcode Generation::Image; ""]
#Better error correction and size 10
Set Variable [$r; Value:MBS( "Barcode.SetOptions"; 3; 10 )]
#Generate QRCode with UTF-8
Set Variable [$img; Value:MBS("Barcode.Generate"; "QRCode"; Barcode Generation::Text; 0; 0; 0; 1; 0; 1; "UTF-8")]
If [GetAsNumber($img) > 0]
    Set Field [Barcode Generation::Image; MBS( "GMImage.WriteToPNGContainer"; $img; "barcode.png")]
    Set Variable [$r; Value:MBS( "GMImage.Release"; $img )]
End If

Create a data matrix barcode with size 10 and return as container:

Let ( [
// set options for Size 10 (32x32) square for data matrix
r = MBS("Barcode.SetOptions"; 0; 10; 100);
// create a data matrix barcode
p = MBS("Barcode.Generate"; "DATAMATRIX"; "12818670,3,1" ; 0; 0; 0; 4);
// success?
e1 = MBS("IsError");
// save as PNG
image = MBS( "GMImage.WriteToPNGContainer"; p; "barcode.png" );
// success?
e2 = MBS("IsError");
// free image from memory
r = MBS("GMImage.Release"; p)
// return container if no error
]; If(e1 = 0 and e2 = 0; image; "") )

Create Maxicode with mode 3:

Set Variable [ $p ; Value: "196LS97TF826004" // primary text ]
Set Variable [ $t ; Value: "1Z42015596UPSN123W123456/11NLEEDS" // second text ]
Set Variable [ $r ; Value: MBS("Barcode.SetOptions"; 3) ]
Set Variable [ $r ; Value: MBS("Barcode.SetPrimary"; $p) ]
Set Variable [ $img ; Value: MBS("Barcode.Generate"; "maxicode"; $t) ]

See also

Example Databases

Blog Entries

This function is free to use.

Created 18th August 2014, last changed 17th November 2022


Barcode.SetOption - Barcode.SetPrimary