Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server (Not)   Client   Old   Guides
New in version: 5.4   6.0   6.1   6.2   6.3   6.4   6.5   7.0   7.1   7.2    Statistic  

Barcode.Generate

Generates a barcode.

Component: Barcode
Version: 3.5
Mac OS X: Yes
Windows: Yes
Server: Yes
FileMaker Cloud: Yes

MBS( "Barcode.Generate"; symbology; Text { ; width; height; rotation; scale; transparent; ShowText; Encoding } )

Parameters

Parameter Description Example value
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 Optional
The desired width of the barcode in pixels. Zero gives the auto size.
0
height Optional
The desired height of the barcode in pixels. Zero gives the auto size.
0
rotation Optional
The rotation. Can be 0, 90, 180 or 270.
0
scale Optional
The scale of the target image.
1.0
transparent Optional
Pass 1 to have the white background being transparent.
1
ShowText Optional
Whether to show text. Use 0 to hide text or 1 to show text.
1
Encoding Optional
The text encoding for text parameter.
Default is UTF-8.
Possible encoding names: ANSI, Arabic-Mac, Arabic-Win, Baltic-Win, CentralEurope-Mac, ChineseSimp-Mac, ChineseSimp-Win, ChineseTrad-Mac, ChineseTrad-Win, Cyrillic-Mac, Cyrillic-Win, EasternEurope-Win, Greek-Mac, Greek-Win, Hebrew-Mac, Hebrew-Win, ISO-8859-1, ISO-8859-2, ISO-8859-3, ISO-8859-4, ISO-8859-5, ISO-8859-6, ISO-8859-7, ISO-8859-8, ISO-8859-9, ISO-8859-15, Korean-Johab, Korean-Mac, Korean-Win, Latin1, Mac, Native, ShiftJIS-Mac, ShiftJIS-Win, Turkish-Mac, Turkish-Win, UTF-8, DOS or Windows. Pass native to use the native encoding of the current platform.
UTF8

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, 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 and GRIDMATRIX.
Please use EANX for EAN-8 and EAN-13. You may need to leave away the check digit for some barcodes.
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.Destroy function.
For the size, be aware that some types like UPC codes have fixed size depending on content.

See also Barcode.SetOptions for further options.

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.Destroy"; $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.Destroy"; $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.Destroy"; $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.Destroy"; 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.Destroy"; $img )]
End If

See also


Barcode.EANChecksum   -   Barcode.GetPrimary

Feedback: Report problem or ask question.




Links
MBS Realbasic Plugins - Pfarrgemeinde St. Arnulf Nickenich