| 1 | package HTML::Barcode::Code93; | ||
| 2 | 2 | ▶ | use Any::Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 2 | extends 'HTML::Barcode::1D'; | |
| 4 | 2 | ▶ | use Barcode::Code93; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 2 | our $VERSION = '0.12'; | |
| 7 | |||
| 8 | has '_code93' => ( | ||
| 9 | is => 'ro', | ||
| 10 | 0 | ▶ | default => sub { Barcode::Code93->new }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 11 | 2 | ); | |
| 12 | |||
| 13 | sub barcode_data { | ||
| 14 | 1 | ▶ | my ($self) = @_; |
|
Subroutine
barcode_data: called CC=1 SCAR=0.0
Pod
documented
| |||
| 15 | 1 | return $self->_code93->barcode(uc $self->text); | |
| 16 | } | ||
| 17 | |||
| 18 | =head1 NAME | ||
| 19 | |||
| 20 | HTML::Barcode::Code93 - Generate HTML representations of Code 93 barcodes | ||
| 21 | |||
| 22 | =head1 SYNOPSIS | ||
| 23 | |||
| 24 | my $code = HTML::Barcode::Code93->new(text => 'MONKEY'); | ||
| 25 | print $code->render; | ||
| 26 | |||
| 27 | =head1 DESCRIPTION | ||
| 28 | |||
| 29 | This class allows you to easily create HTML representations of Code 93 barcodes. | ||
| 30 | |||
| 31 | =begin html | ||
| 32 | |||
| 33 | <p>Here is an example of a Code 93 barcode rendered with this module:</p> | ||
| 34 | |||
| 35 | <table style="border:0;margin:0;padding:0;border-spacing:0;" class="hbc"><tr style="border:0;margin:0;padding:0;"><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#fff;color:inherit;text-align:center;" class="hbc_off"></td><td style="border:0;margin:0;padding:0;width:2px;height:100px;background-color:#000;color:inherit;text-align:center;" class="hbc_on"></td></tr><tr style="border:0;margin:0;padding:0;"><td style="border:0;margin:0;padding:0;width:auto;height:auto;background-color:#fff;color:inherit;text-align:center;" colspan="91">MONKEY</td></tr></table> | ||
| 36 | |||
| 37 | =end html | ||
| 38 | |||
| 39 | You can read more about Code 93 online (e.g. L<http://en.wikipedia.org/wiki/Code_93>). | ||
| 40 | |||
| 41 | =head1 METHODS | ||
| 42 | |||
| 43 | =head2 new (%attributes) | ||
| 44 | |||
| 45 | Instantiate a new HTML::Barcode::Code93 object. The C<%attributes> hash | ||
| 46 | requires the L</text> attribute, and can take any of the other | ||
| 47 | L<attributes|/ATTRIBUTES> listed below. | ||
| 48 | |||
| 49 | =head2 render | ||
| 50 | |||
| 51 | This is a convenience routine which returns C<< <style>...</style> >> tags | ||
| 52 | and the rendered barcode. | ||
| 53 | |||
| 54 | If you are printing multiple barcodes or want to ensure your C<style> tags | ||
| 55 | are in your HTML headers, then you probably want to output the barcode | ||
| 56 | and style separately with L</render_barcode> and | ||
| 57 | L</css>. | ||
| 58 | |||
| 59 | =head2 render_barcode | ||
| 60 | |||
| 61 | Returns only the rendered barcode. You will need to provide stylesheets | ||
| 62 | separately, either writing them yourself or using the output of L</css>. | ||
| 63 | |||
| 64 | =head2 css | ||
| 65 | |||
| 66 | Returns CSS needed to properly display your rendered barcode. This is | ||
| 67 | only necessary if you are using L</render_barcode> instead of the | ||
| 68 | easier L</render> method. | ||
| 69 | |||
| 70 | =head1 ATTRIBUTES | ||
| 71 | |||
| 72 | These attributes can be passed to L<new|/"new (%attributes)">, or used | ||
| 73 | as accessors. | ||
| 74 | |||
| 75 | =head2 text | ||
| 76 | |||
| 77 | B<Required> - The information to put into the barcode. | ||
| 78 | |||
| 79 | =head2 foreground_color | ||
| 80 | |||
| 81 | A CSS color value (e.g. '#000' or 'black') for the foreground. Default is '#000'. | ||
| 82 | |||
| 83 | =head2 background_color | ||
| 84 | |||
| 85 | A CSS color value background. Default is '#fff'. | ||
| 86 | |||
| 87 | =head2 bar_width | ||
| 88 | |||
| 89 | A CSS value for the width of an individual bar. Default is '2px'. | ||
| 90 | |||
| 91 | =head2 bar_height | ||
| 92 | |||
| 93 | A CSS value for the height of an individual bar. Default is '100px'. | ||
| 94 | |||
| 95 | =head2 show_text | ||
| 96 | |||
| 97 | Boolean, default true. Indicates whether or not to render the text | ||
| 98 | below the barcode. | ||
| 99 | |||
| 100 | =head2 css_class | ||
| 101 | |||
| 102 | The value for the C<class> attribute applied to any container tags | ||
| 103 | in the HTML (e.g. C<table> or C<div>). | ||
| 104 | C<td> tags within the table will have either css_class_on or css_class_off | ||
| 105 | classes applied to them. | ||
| 106 | |||
| 107 | For example, if css_class is "barcode", you will get C<< <table class="barcode"> >> and its cells will be either C<< <td class="barcode_on"> >> or | ||
| 108 | C<< <td class="barcode_off"> >>. | ||
| 109 | |||
| 110 | =head2 embed_style | ||
| 111 | |||
| 112 | Rather than rendering CSS stylesheets, embed the style information | ||
| 113 | in HTML C<style> attributes. You should not use this option without | ||
| 114 | good reason, as it greatly increases the size of the generated markup, | ||
| 115 | and makes it impossible to override with stylesheets. | ||
| 116 | |||
| 117 | =head1 AUTHOR | ||
| 118 | |||
| 119 | Mark A. Stratman, C<< <stratman@gmail.com> >> | ||
| 120 | |||
| 121 | =head1 SOURCE REPOSITORY | ||
| 122 | |||
| 123 | L<http://github.com/mstratman/HTML-Barcode-Code93> | ||
| 124 | |||
| 125 | =head1 SEE ALSO | ||
| 126 | |||
| 127 | L<Barcode::Code93> | ||
| 128 | |||
| 129 | =head1 LICENSE AND COPYRIGHT | ||
| 130 | |||
| 131 | Copyright 2011 Mark A. Stratman. | ||
| 132 | |||
| 133 | This program is free software; you can redistribute it and/or modify it | ||
| 134 | under the terms of either: the GNU General Public License as published | ||
| 135 | by the Free Software Foundation; or the Artistic License. | ||
| 136 | |||
| 137 | See http://dev.perl.org/licenses/ for more information. | ||
| 138 | |||
| 139 | |||
| 140 | =cut | ||
| 141 | |||
| 142 | 2 | ▶ | no Any::Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 143 | 2 | 1; # End of HTML::Barcode | |