Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
Barcode.Generate
Generates a barcode.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
Barcode | 3.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameters
Parameter | Description | Example | Flags |
---|---|---|---|
symbology | The symbology to use. e.g. EANX for EAN-13. Another possibility is to lookup the symbology code in the zint manual and pass the number here. EANX is 13 for example. |
"EANX" | |
Text | The text to encode in the barcode. | "12345" | |
width | The desired width of the barcode in pixels. Zero gives the auto size. |
0 | Optional |
height | The desired height of the barcode in pixels. Zero gives the auto size. |
0 | Optional |
rotation | The rotation. Can be 0, 90, 180 or 270. | 0 | Optional |
scale | The scale of the target image. Please use at least 4 for printing the barcode. |
1.0 | Optional |
Transparent | 0: black on white 1: black on transparent background 2: white on black (new in 7.2) 3: white on transparent background (new in 7.2) |
1 | Optional |
ShowText | Whether to show text. Use 0 to hide text or 1 to show text. | 1 | Optional |
Encoding | The text encoding for text parameter. Default is UTF-8. Possible encoding names: ANSI, ISO-8859-1, Latin1, Mac, Native, UTF-8, DOS, Hex, Base64 or Windows. More listed in the FAQ. |
UTF8 | Optional |
Result
Returns GMImage reference or error.
Description
Generates a barcode.The plugin uses zint library internally, so we include the zint manual in documentation.
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. Or the size class for QRCode is calculated based on the text length.
See also Barcode.SetOptions for further options.
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.
You can use GMImage.SetDepth to customize the bit depth of the returned image before saving. Version 11.0 and further will default to 8 bit here, while 9.0 to 10.5 use 16 bit.
CodeName | Numeric Value | Description |
CODE11 | 1 | Code 11 |
C25STANDARD | 2 | Standard Code 2 of 5 (Matrix) |
C25MATRIX | 2 | Legacy |
C25INTER | 3 | 2 of 5 Interleaved |
C25IATA | 4 | 2 of 5 IATA |
C25LOGIC | 6 | 2 of 5 Data Logic |
C25IND | 7 | 2 of 5 Industrial |
CODE39 | 8 | Code 3 of 9 (Code 39) |
EXCODE39 | 9 | Extended Code 3 of 9 (Code 39+) |
EANX | 13 | EAN (European Article Number) |
EANX_CHK | 14 | EAN + Check Digit |
GS1_128 | 16 | GS1-128 (UCC.EAN-128) |
EAN128 | 16 | Code 128 (automatic subset switching) |
CODABAR | 18 | Codabar |
CODE128 | 20 | Code 128 |
DPLEIT | 21 | Deutsche Post Leitcode |
DPIDENT | 22 | Deutsche Post Identcode |
CODE16K | 23 | Code 16k |
CODE49 | 24 | Code 49 |
CODE93 | 25 | Code 93 |
FLAT | 28 | Flattermarken |
DBAR_OMN | 29 | GS1 DataBar Omnidirectional |
RSS14 | 29 | GS1 DataBar-14 |
DBAR_LTD | 30 | GS1 DataBar Limited |
RSS_LTD | 30 | GS1 DataBar Limited |
DBAR_EXP | 31 | GS1 DataBar Expanded |
RSS_EXP | 31 | Legacy |
TELEPEN | 32 | Telepen Alpha |
UPCA | 34 | UPC-A |
UPCA_CHK | 35 | UPC-A + Check Digit |
UPCE | 37 | UPC-E |
UPCE_CHK | 38 | UPC-E + Check Digit |
POSTNET | 40 | USPS (U.S. Postal Service) POSTNET |
MSI_PLESSEY | 47 | MSI Plessey |
FIM | 49 | Facing Identification Mark |
LOGMARS | 50 | LOGMARS |
PHARMA | 51 | Pharmacode One-Track |
PZN | 52 | Pharmazentralnummer |
PHARMA_TWO | 53 | Pharmacode Two-Track |
CEPNET | 54 | Brazilian CEPNet Postal Code |
PDF417 | 55 | PDF417 |
PDF417COMP | 56 | Compact PDF417 (Truncated PDF417) |
PDF417TRUNC | 56 | PDF417 Truncated |
MAXICODE | 57 | MaxiCode |
QRCODE | 58 | QR Code |
CODE128B | 60 | Code 128 (Subset B) |
AUSPOST | 63 | Australia Post Standard Customer |
AUSREPLY | 66 | Australia Post Reply Paid |
AUSROUTE | 67 | Australia Post Routing |
AUSREDIRECT | 68 | Australia Post Redirection |
ISBNX | 69 | ISBN (EAN-13 with verification stage) |
RM4SCC | 70 | Royal Mail 4-State Customer Code (RM4SCC) |
DATAMATRIX | 71 | Data Matrix (ECC200) |
EAN14 | 72 | EAN-14 |
VIN | 73 | Vehicle Identification Number |
CODABLOCKF | 74 | Codablock-F |
NVE18 | 75 | NVE-18 (SSCC-18) |
JAPANPOST | 76 | Japanese Postal Code |
KOREAPOST | 77 | Korea Post |
DBAR_STK | 79 | GS1 DataBar Stacked |
RSS14STACK | 79 | GS1 DataBar-14 Stacked |
DBAR_OMNSTK | 80 | GS1 DataBar Stacked Omnidirectional |
RSS14STACK_OMNI | 80 | GS1 DataBar-14 Stacked Omnidirectional |
DBAR_EXPSTK | 81 | GS1 DataBar Expanded Stacked |
RSS_EXPSTACK | 81 | GS1 DataBar Expanded Stacked |
PLANET | 82 | USPS PLANET |
MICROPDF417 | 84 | MicroPDF417 |
USPS_IMAIL | 85 | USPS Intelligent Mail (OneCode) |
ONECODE | 85 | USPS OneCode |
PLESSEY | 86 | UK Plessey |
TELEPEN_NUM | 87 | Telepen Numeric |
ITF14 | 89 | ITF-14 |
KIX | 90 | Dutch Post KIX Code |
AZTEC | 92 | Aztec Code |
DAFT | 93 | DAFT Code |
DPD | 96 | DPD Code |
MICROQR | 97 | Micro QR Code |
HIBC_128 | 98 | HIBC (Health Industry Barcode) Code 128 |
HIBC_39 | 99 | HIBC Code 39 |
HIBC_DM | 102 | HIBC Data Matrix |
HIBC_QR | 104 | HIBC QR Code |
HIBC_PDF | 106 | HIBC PDF417 |
HIBC_MICPDF | 108 | HIBC MicroPDF417 |
HIBC_BLOCKF | 110 | HIBC Codablock-F |
HIBC_AZTEC | 112 | HIBC Aztec Code |
DOTCODE | 115 | DotCode |
HANXIN | 116 | Han Xin (Chinese Sensible) Code |
MAILMARK | 121 | Royal Mail 4-State Mailmark |
AZRUNE | 128 | Aztec Runes |
CODE32 | 129 | Code 32 |
EANX_CC | 130 | Composite Symbol with EAN linear component |
GS1_128_CC | 131 | GS1-128 Composite |
EAN128_CC | 131 | Composite Symbol with GS1-128 linear component |
DBAR_OMN_CC | 132 | GS1 DataBar Omnidirectional Composite |
RSS14_CC | 132 | Composite Symbol with GS1 DataBar-14 linear component |
DBAR_LTD_CC | 133 | GS1 DataBar Limited Composite |
RSS_LTD_CC | 133 | Composite Symbol with GS1 DataBar Limited component |
DBAR_EXP_CC | 134 | GS1 DataBar Expanded Composite |
RSS_EXP_CC | 134 | Composite Symbol with GS1 DataBar Extended component |
UPCA_CC | 135 | Composite Symbol with UPC A linear component |
UPCE_CC | 136 | Composite Symbol with UPC E linear component |
DBAR_STK_CC | 137 | GS1 DataBar Stacked Composite |
RSS14STACK_CC | 137 | Composite Symbol with GS1 DataBar-14 Stacked component |
DBAR_OMNSTK_CC | 138 | GS1 DataBar Stacked Omnidirectional Composite |
RSS14_OMNI_CC | 138 | Composite Symbol with GS1 DataBar-14 Stacked Omnidirectional component |
DBAR_EXPSTK_CC | 139 | GS1 DataBar Expanded Stacked Composite |
RSS_EXPSTACK_CC | 139 | Composite Symbol with GS1 DataBar Expanded Stacked component |
CHANNEL | 140 | Channel Code |
CODEONE | 141 | Code One |
GRIDMATRIX | 142 | Grid Matrix |
UPNQR | 143 | UPNQR (Univerzalnega Plačilnega Naloga QR) |
ULTRA | 144 | Ultracode |
RMQR | 145 | Rectangular Micro QR Code (rMQR) |
BC412 | 146 | IBM BC412 (SEMI T1-95) |
Examples
Creates UPCA barcode:
MBS( "Barcode.Generate"; "UPCA"; "72527270270")
Create ISDN 9780271016368 barcode with EAN:
MBS( "Barcode.Generate"; "EANX"; "978027101636")
Make a barcode and store it as PNG in a container:
Set Variable [$image; Value:MBS( "Barcode.Generate"; "UPCA"; "72527270270")]
If [MBS("isError") = 0]
Set Field [MyTable::BarCodeContainer; MBS( "GMImage.WriteToPNGContainer"; $image; "barcode.png" )]
Set Variable [$r; Value:MBS("GMImage.Release"; $image)]
Else
Set Field [MyTable::BarCodeContainer; ""]
End If
Generate EAN 128
MBS( "Barcode.Generate"; "EAN128"; "[00]993262210000005384")
Generate UPCA barcode:
Set Variable [ $Barcode ; Value: MBS( "Barcode.Generate"; "UPCA"; "76837100000"; 0; 0; 0; 1; 1; 1; "UTF8" ) ]
If [ MBS( "IsError" ) = 0 ]
Set Field [ test::Barcode ; MBS("GMImage.WriteToPNGContainer"; $Barcode; "768371000004.png") ]
Set Variable [ $r ; Value: MBS("GMImage.Release"; $Barcode) ]
Else
Set Field [ test::Barcode ; "" ]
End If
Create a barcode and change color to red:
Set Field [Barcode Generation::Image; ""]
Set Variable [$img; Value:MBS("Barcode.Generate"; Barcode Generation::Symbology; Barcode Generation::Text)]
If [GetAsNumber($img) > 0]
Set Variable [$r; Value:MBS("GMImage.SetType"; $img; 7)]
Set Variable [$r; Value:MBS( "GMImage.ReplaceColor"; $img; "black"; "red"; 3)]
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; "") )
Generate Maxicode with mode=4:
Set Field [Barcode Generation::Image; ""]
Set Variable [$img; Value:MBS("Barcode.SetOptions"; 4)]
Set Variable [$img; Value:MBS("Barcode.Generate"; "MAXICODE"; "A MaxiCode Message in Mode 4")]
If [MBS("IsError") = 0]
Set Field [Barcode Generation::Image; MBS( "GMImage.WriteToPNGContainer"; $img; "barcode.png")]
Set Variable [$r; Value:MBS( "GMImage.Release"; $img )]
End If
Example for Maxicode creation, e.g. for UPS:
Set Variable [ $p ; Value: "LS97TF 826004" // primary text ]
Set Variable [ $t ; Value: "[)>{RS}01{GS}961Z42015596{GS}UPSN{GS}123W45{GS}339{GS}{GS}1/1{GS}1{GS}N{GS}{GS}LEEDS{GS}{RS}{EOT}" ]
Set Variable [ $t ; Value: Substitute($t; "{EOT}"; Char(4)) ]
Set Variable [ $t ; Value: Substitute($t; "{RS}"; Char(30)) ]
Set Variable [ $t ; Value: Substitute($t; "{GS}"; Char(29)) ]
Set Variable [ $r ; Value: MBS("Barcode.SetOptions"; 3) ]
// Set Variable [ $r ; Value: MBS( "Barcode.SetInputMode"; "data" ) ]
Set Variable [ $r ; Value: MBS( "Barcode.SetInputMode"; "unicode" ) ]
Set Variable [ $r ; Value: MBS("Barcode.SetPrimary"; $p) ]
Set Variable [ $img ; Value: MBS("Barcode.Generate"; "maxicode"; $t) ]
Set Field [ Barcode Generation::Image ; MBS( "GMImage.WriteToPNGContainer"; $img ) ]
Set Variable [ $r ; Value: MBS("GMImage.Release"; $img) ]
Create barcode and crop it:
Set Field [ Barcode Generation::Image ; "" ]
Set Variable [ $img ; Value: MBS("Barcode.Generate"; Barcode Generation::Symbology; Barcode Generation::Text) ]
If [ MBS("IsError") = 0 ]
Set Variable [ $ImageHeight ; Value: MBS("GMImage.GetHeight"; $img) ]
Set Variable [ $ImageWidth ; Value: MBS("GMImage.GetWidth"; $img) ]
# calculate the crop rectangle
Set Variable [ $w ; Value: $ImageWidth ]
Set Variable [ $h ; Value: $ImageHeight ]
Set Variable [ $x ; Value: 0 ]
Set Variable [ $y ; Value: $ImageHeight - 50 ]
# crop
Set Variable [ $r ; Value: MBS("GMImage.Crop"; $img; $w & "x" & $h & "+" & $x & "+" & $y) ]
Set Field [ Barcode Generation::Image ; MBS( "GMImage.WriteToPNGContainer"; $img; "barcode.png") ]
Set Variable [ $r ; Value: MBS( "GMImage.Release"; $img ) ]
End If
Create barcode and cut away top half to get wider EAN codes:
Set Field [ Barcode Generation::Image ; "" ]
Set Variable [ $img ; Value: MBS( "Barcode.Generate"; /* Generates a barcode. */ Barcode Generation::Symbology; /* The symbology to use. e.g. EANX for EAN-13. Another possibility is to lookup the symbology code in the zint manual and pass the number here. EANX is 13 for example.e.g.… ]
If [ MBS("IsError") = 0 ]
# crop to top half
Set Variable [ $h ; Value: MBS("GMImage.GetHeight"; $img) ]
Set Variable [ $w ; Value: MBS("GMImage.GetWidth"; $img) ]
Set Variable [ $r ; Value: MBS("GMImage.Crop"; $img; $w & "x" & ($h/2) & "+0+" & ($h/2)) ]
Set Field [ Barcode Generation::Image ; MBS( "GMImage.WriteToPNGContainer"; $img; "barcode.png") ]
Set Variable [ $r ; Value: MBS( "GMImage.Release"; $img ) ]
End If
Create Code39 barcode in Let statement:
Let ( [
// create a Code39 barcode
p = MBS("Barcode.Generate"; "CODE39"; $Stock ; 160 ; 25 ; 0 ; 2 ; 1 ; 0);
// 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 a CMYK picture for barcode:
Set Variable [ $img ; Value: MBS( "Barcode.Generate"; /* Generates a barcode. */
Barcode Generation::Symbology; /* The symbology to use. e.g. EANX for EAN-13.
Another possibility is to lookup the symbology code in the zint manual and pass the number here. EANX is 13 for example.e.g. "EANX" */
Barcode Generation::Text; /* The text to encode in the barcode.e.g. "12345" */
0; /* Optional; The desired width of the barcode in pixels. Zero gives the auto size.e.g. 0 */
0; /* Optional; The desired height of the barcode in pixels. Zero gives the auto size.e.g. 0 */
0; /* Optional; The rotation. Can be 0, 90, 180 or 270.e.g. 0 */
4; /* Optional; The scale of the target image.e.g. 1.0 */
0; /* Optional; 0: black on white */
1; /* Optional; Whether to show text. Use 0 to hide text or 1 to show text.e.g. 1 */
"UTF-8") /* Optional; The text encoding for text parameter.
Default is UTF-8.e.g. UTF8 */]
If [ MBS("IsError") = 0 ]
Set Variable [ $r ; Value: MBS( "GMImage.SetColorSpace"; $img; 10 ) ]
Set Variable [ $r ; Value: MBS( "GMImage.ReplaceColor"; $img; "RGB 1 1 1 1"; "RGB 0 0 0 1"; 10) ]
Set Variable [ $r ; Value: MBS( "GMImage.SetQuality"; $img; 100 ) ]
Set Field [ Barcode Generation::Image ; MBS( "GMImage.WriteToJPEGContainer"; $img; "barcode.jpg") ]
Set Variable [ $r ; Value: MBS( "GMImage.Release"; $img ) ]
End If
Generate code for US Postal Office (USPS):
MBS( "Barcode.Generate"; "OneCode"; "01234567094987654321-012345678")
Creates EAN128 barcode:
MBS( "Barcode.Generate"; "EAN128"; "[01]98898765432106[3202]012345[15]991231")
See also
- Barcode.GenerateJSON
- GMImage.Crop
- GMImage.GetHeight
- GMImage.GetWidth
- GMImage.Release
- GMImage.ReplaceColor
- GMImage.SetDepth
- GMImage.SetQuality
- GMImage.SetType
- GMImage.WriteToPNGContainer
Release notes
- Version 14.5
- Changed Barcode.Generate, Barcode.GenerateJSON and Barcode.WriteFile to use 4 as default scale.
- Version 13.1
- Fixed problem in Barcode.Generate and Barcode.GenerateJSON functions, where a warning from the zint library would be treated as an error.
- Version 13.0
- Added WhitespaceHeight, GuardDescent and WarnLevel options for Barcode.GenerateJSON functions.
- Version 12.5
- Fixed crash if text is missing in JSON for Barcode.GenerateJSON function.
- Version 11.2
- Added workaround for error 561 in Barcode.Generate. We lower ECC level now if text doesn't fit otherwise.
- Version 11.0
- Changed Barcode.Generate to default to 8-bit per channel for the generated image to avoid trouble if receiving software can't handle 16 bit per channel. You can still change with GMImage.SetDepth, e.g. to make a monochrome version.
- Version 9.4
- Added Barcode.GenerateJSON function.
- Version 7.4
- Fixed bug in Barcode.Generate function with generating barcode without text.
- Version 7.2
- Added option for Barcode.Generate to allow white on black for barcodes.
Example Databases
- Barcode/Barcode Generation
- Barcode/EPC-QR-Code
- Barcode/Swiss QR-Code for invoices/ISO20022 QR v2.0
- Barcode/Swiss QR-Code for invoices/Swiss QR-Code for invoices ISO 20022
Blog Entries
- MBS FileMaker Plugin, version 14.5pr3
- MBS Plugin Advent calendar: 3 - BinaryFile
- MBS Plugin Advent calendar: 1 - Barcodes
- MBS FileMaker Plugin, version 13.1pr4
- Trace with parameter names
- MBS FileMaker Plugin, version 11.2pr1
- Generate EPC-QR-Code in FileMaker
- MBS FileMaker Plugin, version 10.6pr1
- QR Codes for Invoices in Switzerland
- MBS FileMaker Plugin 3.5 for OS X/Windows - More than 2100 Functions In One Plugin
FileMaker Magazin
This function checks for a license.
Created 18th August 2014, last changed 10th September 2024