HTML::Barcode::QRCode - Generate HTML representations of QR codes


Text::QRCode and libqrencode are required by this class, so please install them first.

  my $code = HTML::Barcode::QRCode->new(text => '');
  print $code->render;


This class allows you to easily create HTML representations of QR codes. These are two-dimensional scan codes commonly used to allow people to quickly input a URL into their phone or other mobile device.

Here is an example of a QR code rendered with this module:

This requires Text::QRCode.

You can read more about QR codes online (e.g.


new (%attributes)

Instantiate a new HTML::Barcode::QRCode object. The %attributes hash requires the "text" attribute, and can take any of the other attributes listed below.


This is a convenience routine which returns <style>...</style> tags and the rendered QR code.

If you are printing multiple QR codes or want to ensure your style tags are in your HTML headers, then you probably want to output the QR code and style separately with "render_barcode" and "css".


Returns only the rendered QR code. You will need to provide stylesheets separately, either writing them yourself or using the output of "css".


Returns CSS needed to properly display your rendered QR code. This is only necessary if you are using "render_barcode" instead of the easier "render" method.


These attributes can be passed to new, or used as accessors.


Required - The information to put into the QR code.


A CSS color value (e.g. '#000' or 'black') for the foreground. Default is '#000'.


A CSS color value background. Default is '#fff'.


A CSS value for the width and height of an individual module (a dot) in the code. Default is '3px'.


The value for the class attribute applied to any container tags in the HTML (e.g. table or div). td tags within the table will have either css_class_on or css_class_off classes applied to them.

For example, if css_class is "barcode", you will get <table class="barcode"> and its cells will be either <td class="barcode_on"> or <td class="barcode_off">.


Rather than rendering CSS stylesheets, embed the style information in HTML style attributes. You should not use this option without good reason, as it greatly increases the size of the generated markup, and makes it impossible to override with stylesheets.


Mark A. Stratman, <>



Copyright 2011 Mark A. Stratman.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See for more information.