User Guide
To use the Barcode Creator module, you send the data you want to encode as a script parameter, and you get an image encoded in base 64 as a script result. Then it’s up to you to use FileMaker’s Base64Decode function to convert the base 64 to an image file and store it in a container field. The BarcodeCreator.fmp12 file has an example script that demonstrate how this is done.
In Version 1.3.0 we added a slightly different option. First you use a Go To Field step to select the container field you want, then you run a script with the data you want to encode as a script parameter, which will insert the completed barcode into the field. This may be a little simpler in some cases, although it does require that the target container field be placed on the layout. See the “Simple Example EPS” script for more information on this.
You do have to tell the script a few more details about how you would like to generate the barcode. So there are two different ways to handle the additional data. You can use the “Global Variables” method or the “Let Notation” method. Both are detailed below. You can choose to use whichever version you are more comfortable with.
There are example implementations of each method in the Barcode Creator.fmp12 file. Look at the following Layouts:
- Simple Example – It has a simple example using Let Notation. It is focused on learning rather than robust error trapping.
- Simple Example EPS – this is an example of how to generate EPS barcodes.
- Advanced Example – It has both methods, is very detailed and has lots of error trapping
The scripts that drive these layouts are in the Scripts folder called “Examples”.
Image Types
Barcode Creator supports PNG barcode images on all platforms. In version 1.3.o we added support for the EPS image type.The EPS file format is vector based and therefor scales up or down with no pixelating like you get with bitmap formats (PNG).
While Barcode Creator creates the EPS image correctly on all FileMaker supported devices and browsers, a bug in FileMaker prevents the barcode from being visible in container fields on anything other than Mac desktops. If you are printing barcodes as part of a FileMaker layout, you will need to use a Mac to create and print them. If you are going to export the barcodes for using some other design process or send the files directly to a printer that can accept EPS file then you can use any FileMaker supported device or browser.
Symbologies
Both interfaces accept a “symbology” parameter specifying what kind of barcode you want. Barcode Creator currently supports these symbologies.
The “Symbologies” layout folder in the Barcode Creator.fmp12 files contains layouts describing and testing each of these.
Global Variables
Using global variables is the easier of the two interfaces. Set the following global variables with the options you want, then pass your barcode data as a script parameter to the “Render Barcode as Base 64 ( dataToEncode )” script.
$$ BARCODE_SYMBOLOGY (see “Intro” tab) $$BARCODE_WIDTH (in pixels) $$BARCODE_HEIGHT (in pixels) $IMAGE_TYPE : (optional) one of “png” or “eps”. defaults to “png” $$BARCODE_ERROR_CORRECTION_CAPACITY $$BARCODE_USE_ESCAPE_SEQUENCES (boolean)
$$BARCODE_WIDTH and $$BARCODE_HEIGHT are now optional ( as of version 1.4 ). See below for more information.
$$BARCODE_USE_ESCAPE_SEQUENCE S bears some explaining. The Code 128 and QR Code symbologies can encode many characters and function codes that can be difficult to represent as standard text, such as ASCII control characters and barcode-specific function codes. Some of those characters are impossible to type on a keyboard, so the Barcode Creator has an option to recognize certain escape sequences. When that last global variable is set to True (1), the module will look for and interpret escape sequences in your data. Otherwise, it will just treat every incoming character as-is.
$$BARCODE_ERROR_CORRECTION_CAPACITY is a number in between 0 and 1 representing the desired error correction capacity for some barcodes, such as QR Code. The actual error correction level may be rounded to fit one of QR Code’s predefined levels. Defaults to .1.
If there’s a problem rendering your barcode, the script result will be an error message instead of base 64 data. Error messages always start with the word “Error”. The same error message will also be set to the $$BARCODE_ERROR variable.
Let Notation
FilemakerStandards.org on Let Notation
If you don’t want a series of global variables crowding your data viewer in FileMaker Pro Advanced, or if you want more details about your barcode, you can use the Let Notation interface. Let Notation is a popular format for passing multiple parameters to and from scripts in FileMaker.
The “Render Barcode as Base 64 ( $dataToEncode ; $width ; $height ) { $symbology ; … }” script accepts the following parameters in Let Notation:
$dataToEncode: The data to encode in the barcode $width: In pixels $height: In pixels $imageType : (optional) one of “png” or “eps”. defaults to “png” $symbology: (see the “Intro” tab) errorCorrectionCapacity $useEscapeSequences
$width and $height are now optional ( as of version 1.4 ). See below for more information.
$useEscapeSequences bears some explaining. The Code 128 and QR Code symbologies can encode many characters and function codes that can be difficult to represent as standard text, such as ASCII control characters and barcode-specific function codes. Some of those characters are impossible to type on a keyboard, so the Barcode Creator has an option to recognize certain escape sequences. When that last global variable is set to True (1), the module will look for and interpret escape sequences in your data. Otherwise, it will just treat every incoming character as-is.
$errorCorrectionCapacity is a number in between 0 and 1 representing the desired error correction capacity for some barcodes, such as QR Code. The actual error correction level may be rounded to fit one of QR Code’s predefined levels. Defaults to .1.
The script returns the following results in Let Notation:
$base64: The encoded barcode image $pixelsPerModule: Pixels of width used for the smallest barcode features $quietZoneWidthInModules: Size of quiet zones in barcode image $errorMessage $errorCode
In the event of an error, $errorCode will be some number other than zero, and $errorMessage will describe the problem.
Insert Barcode in Current Field Scripts
As of version 1.3, there are two new scripts that you can use to generate barcodes
- Insert Barcode in Current Field ( dataToEncode )
- Insert Barcode in Current Field ( $dataToEncode ) { $symbology ; $width ; $height ; ... }
These work just like the "Render Barcode as Base64" versions accept that they do the Base64 Decode and set the image into the field for you. The target field does need to be on the current layout and active at the time the script is called for this to work.
Width and Height
As of version 1.4, Width and Height parameters are now optional. If they are left out, the Render scripts will handle setting the width and height. When you use either of the "Render Barcode as Base 64" scripts Barcode Creator will pick the best width and height for the symbology. When you use the "Insert Barcode in Current Field" scripts, Barcode Creator will use the width and height of the target field. $$