The foswiki svn repository is obsolete. Developers should register for a account for commit access to foswiki project. Github is ready for updates.


This plugin is used to create embedded barcodes in topics. Currently only Code128 codes are supported. Support for other standard codes could easily be added for any standard supported by Perl Barcode or CPAN:GD::Barcode modules.

The original inspiration for this was so I could generate barcodes that can be read by a CueCat

One useful application is to print out a page with the Topic name encoded in the barcode. Then use the scanner to quickly jump to the Wiki page for editing. eg,. %BARCODE{text="%TOPIC%"}%


Syntax Rules

The %BARCODE{parm="value" ...}% variable gets expanded to an image representing the barcode.

%Barcode% Parameter CommentSorted ascending Default
transparent_text 0/1: use transparent background for text? 1 - Transparent
show_text 0/1: Show text under the barcode 1 - Text is shown
cue_cat 0/1: Swap upper and lower case for Cue Cat 0 - No swap
font_align Align the text ("left", "right", or "center") "center"
font Font for the text at the bottom. Font may be one of the following: "giant", "large", "medium", "small", or "tiny". Or, it may be any valid GD font name, such as "gdMediumFont". "medium"
height Height of barcode. Set to "0" for minimum size. Must be at least 15% of the width of the final barcode. 0
scale How many pixels for the smallest barcode stripe 2
border Size of the black border around the barcode 0
padding Size of whitespace before & after barcode 5
text The text to encode "R.T.F.M."

BarcodePlugin Settings

Plugin settings are stored as preferences variables. To reference a plugin setting write %<plugin>_<setting>%, for example, %DEFAULTPLUGIN_SHORTDESCRIPTION%

  • One line description, shown in the TextFormattingRules topic:
    • Set SHORTDESCRIPTION = This plugin creates embedded Code128 barcodes in a page.

  • Debug plugin: (See output in data/debug.txt)
    • Set DEBUG = 0


You type ... Expect output If Installed
%BARCODE{text="Hello" transparent_text="0" height="0" }% example_0.png %BARCODE{text="Hello" transparent_text="0" height="50"}%
%BARCODE{text="BarcodePlugin2004" scale="1"}% example_1.png %BARCODE{text="Barcode01234" scale="1"}%

I use this to generate a table of topics with the topic encoded in a barcode. I then use a cuecat to scan the barcode and take me to the relevent page. Here is the verbatim code, note the use of the "$percent" to escape the BARCODE tag in the formatted search:

%TABLE{ sort="on" tableborder="1" cellpadding="1" cellspacing="3" headerbg="#666699" 
headercolor="#FFFFCC" databg="#CCCCCC, #EFEFEF" headerrows="1" footerrows="1" }%
|*Box Database</b>%ENDCOLOR%*||||
|*Box #*|*Location*|*Owner*|*Barcode*|*Contents*|
%SEARCH{ "HouseBox[0-9][0-9][0-9]" scope="topic" regex="on" nosearch="on" nototal="on" format="
| [[$topic]] | $formfield(HouseBoxLocations) |  $formfield(HouseBoxOwners) 
| $percntBARCODE{text=$topic scale=1 padding=20}$nop% 
|$formfield(Description)|" }%

Plugin Installation Instructions

Note: You do not need to install anything on your browser to use this plugin. The following instructions are for the administrator who installs the plugin on the server where Foswiki is running.

  • Make sure your Perl administrator has installed the Barcode::Code128 module. (perl -MCPAN -e "install Barcode::Code128")
  • Make sure you have GD 1.20 or later installed.
  • Download the ZIP file from the Plugin web (see below)
  • Unzip in your Foswiki installation directory. Content:
    File: Description:
    lib/Foswiki/Plugins/ Plugin Perl module
    data/System/BarcodePlugin.txt Plugin topic
    pub/System/BarcodePlugin/example_0.png Sample barcode image
    pub/System/BarcodePlugin/example_1.png Sample barcode image
  • Visit configure in your Foswiki installation, and enable the plugin in the {Plugins} section.
  • Test if the plugin is correctly installed:
    • Check above examples if the "if installed" column shows images instead of variables.

Plugin Info

Plugin Author: Original: TWiki:Main/StevenSprouse / Ported to Foswiki by Foswiki:Main.WillNorris and Foswiki:Main.KennethLavrsen
Plugin Version: 1.004 (30 Mar 2009)
Change History:  
30 Mar 2009 v1.004 - Directory paths fixed and extention released on
15 Dec 2008 v1.003 - Rebranded to Foswiki
11 Nov 2004 v1.002 - Improved benchmarks by changing Perl module load timing.
5 Nov 2004 v1.001 - Added cue_cat flag
4 Nov 2004 v1.000 - Initial release
Foswiki Dependency: $Foswiki::Plugins::VERSION 1.024
CPAN Dependencies: CPAN:Barcode::Code128
  CPAN:GD v1.20 or later
Other Dependencies: none
Perl Version: 5.8
Plugin Home:

Related Topics: DefaultPreferences, SitePreferences, Plugins
Topic revision: r5 - 10 Dec 2009, CrawfordCurrie
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. see CopyrightStatement. Creative Commons License