.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Barcode 3pm" .TH Barcode 3pm "2022-06-16" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" PDF::Reuse::Barcode \- Create barcodes for PDF documents with PDF::Reuse .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 3 \& use PDF::Reuse; \& use PDF::Reuse::Barcode; \& use strict; \& \& prFile(\*(Aqbars.pdf\*(Aq); \& \& PDF::Reuse::Barcode::ITF (x => 70, \& y => 530, \& value => \*(Aq0123456789\*(Aq, \& prolong => 2.96); \& \& prEnd(); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This is a sub-module to PDF::Reuse. It creates barcode \*(L"images\*(R" to be used in \&\s-1PDF\s0 documents. It uses GD::Barcode and its sub-modules: GD::Barcode::Code39, COOP2of5, \s-1EAN13\s0 and so on, to calculate the barcode pattern. For Code128 it uses Barcode::Code128. .PP Normally the barcodes are displayed on a white background and with the characters under the bars. You can rotate the \*(L"image\*(R", make it smaller or bigger, prolong the bars and change the background. (But then, don't forget to test that your barcode scanner still understands it.) .PP If you don't change the size of the \*(L"image\*(R", the bars are approximately 24 pixels high (the guard bars a few pixels longer) and the box/background is 38 pixels high and something like 20 pixels wider than the barcodes. The text under the bars are 10 pixels high. .SH "FUNCTIONS" .IX Header "FUNCTIONS" All functions are called in a similar way. Just replace '\s-1ITF\s0' in the example under \s-1SYNOPSIS\s0 with some other function name and let the value parameter follow the rules of that function. .SS "Code128" .IX Subsection "Code128" Creates Code128 barcodes with the help of Barcode::Code128. Look at that module for further information. .PP .Vb 1 \& # code128.pl \& \& use PDF::Reuse; \& use PDF::Reuse::Barcode; \& prFile(\*(Aqcode128.pdf\*(Aq); \& PDF::Reuse::Barcode::Code128(x => 100, \& y => 730, \& value => \*(Aq00000123455555555558\*(Aq); \& prEnd(); .Ve .PP The constants CodeA, \s-1FNC1, SHIFT\s0 and so on, are not imported, but if you really need them (??), try to use the character values instead. .PP .Vb 4 \& CodeA 0xf4 CodeB 0xf5 CodeC 0xf6 \& FNC1 0xf7 FNC2 0xf8 FNC3 0xf9 \& FNC4 0xfa Shift 0xfb StartA 0xfc \& StartB 0xfd StartC 0xfe Stop 0xff \& \& # unusual.pl \& \& # Instead of FCN1 \& \& use PDF::Reuse; \& use PDF::Reuse::Barcode; \& prFile(\*(Aqunusual.pdf\*(Aq); \& PDF::Reuse::Barcode::Code128(x => 100, \& y => 430, \& value => chr(0xf7) . \*(Aq00000123455555555558\*(Aq, \& text => 0 ); \& \& # Font and font size has to be chosen \& # Text could be put manually at x => 110 \& # y => 431 \& # The size, xSize, ySize and rotation doesn\*(Aqt influence the text \& # in this case ... \& \& prEnd(); .Ve .SS "Code39" .IX Subsection "Code39" Translates the characters 0\-9, A\-Z, '\-', '*', '+', '$', '%', '/', '.' and ' ' to a barcode pattern. .PP In Code39, the asterisk is used as the start and stop bar, but PDF::Reuse::Barcode expects you to supply the asterisks. If you do not want them to display in the text version, pass the option \*(L"hide_asterisk\*(R" as in .PP .Vb 4 \& PDF::Reuse::Barcode::Code39 (x => 10, \& y => 20, \& value => \*(Aq*62002*\*(Aq, \& hide_asterisk => 1); .Ve .SS "COOP2of5" .IX Subsection "COOP2of5" Creates COOP2of5 barcodes from a string consisting of the numeric characters 0\-9 .SS "\s-1EAN13\s0" .IX Subsection "EAN13" Creates \s-1EAN13\s0 barcodes from a string of 12 or 13 digits. The check number (the 13:th digit) is calculated if not supplied. If there is given check number it is not controlled. .SS "\s-1EAN8\s0" .IX Subsection "EAN8" Translates a string of 7 or 8 digits to \s-1EAN8\s0 barcodes. The check number (the 8:th digit) is calculated if not supplied. If there is given check number it is not controlled. .SS "IATA2of5" .IX Subsection "IATA2of5" Creates IATA2of5 barcodes from a string consisting of the numeric characters 0\-9 .SS "Industrial2of5" .IX Subsection "Industrial2of5" Creates Industrial2of5 barcodes from a string consisting of the numeric characters 0\-9 .SS "\s-1ITF\s0" .IX Subsection "ITF" Translates the characters 0\-9 to a barcodes. These barcodes could also be called 'Interleaved2of5'. .SS "Matrix2of5" .IX Subsection "Matrix2of5" Creates Matrix2of5 barcodes from a string consisting of the numeric characters 0\-9 .SS "\s-1NW7\s0" .IX Subsection "NW7" Creates a \s-1NW7\s0 barcodes from a string consisting of the numeric characters 0\-9 .SS "QRcode" .IX Subsection "QRcode" Creates QRcodes from numeric, alphanumeric, binary or Kanji data (or a mixture of these). .SS "\s-1UPCA\s0" .IX Subsection "UPCA" Translates a string of 11 or 12 digits to \s-1UPCA\s0 barcodes. The check number (the 12:th digit) is calculated if not supplied. If there is given check number it is not controlled. .SS "\s-1UPCE\s0" .IX Subsection "UPCE" Translates a string of 6, 7 or 8 digits to \s-1UPCE\s0 barcodes. If the string is 6 digits long, '0' is added first in the string. The check number (the 8:th digit) is calculated if not supplied. If there is given check number it is not controlled. .SH "COMMON PARAMETERS" .IX Header "COMMON PARAMETERS" All functions accepts these parameters. The parameters should be put in a hash. All of them are optional, except 'value'. .SS "value" .IX Subsection "value" A string of characters which will be translated to barcodes. .SS "x" .IX Subsection "x" Number of pixels along the x\-axis where to put the lower left \*(L"corner\*(R" of the barcode image. .SS "y" .IX Subsection "y" Number of pixels along the y\-axis where to put the lower left \*(L"corner\*(R" of the barcode image. .SS "size" .IX Subsection "size" A (decimal) number. If you define a number for this parameter, all sizes along the x\- and y\-axes will multiplied by this number. Also the text under the bars will be scaled. .PP For QRcodes, the square of this number determines the number of 'modulesize' rectangles used to represent a single module (so 1=1, 2=4, 3=9, etc). .SS "xSize" .IX Subsection "xSize" A (decimal) number. If you define a number for this parameter, all sizes along the x\-axis will multiplied by this number. The text under the bars are also affected. .SS "ySize" .IX Subsection "ySize" A (decimal) number. If you define a number for this parameter, all sizes along the y\-axis will multiplied by this number. The text under the bars are also affected. .SS "prolong" .IX Subsection "prolong" 0 or a decimal number greater than 1. Prolongs the bars with this factor. In reality tells the module to prolong the bars by repeatedly rewriting the barcode pattern. .SS "text" .IX Subsection "text" Normally this parameter is 'yes', which will cause the digits to be written as text under the barcodes. If this parameter is '' or 0, the text will be suppressed. .SS "drawbackground" .IX Subsection "drawbackground" By default this parameter is 1, which will cause the barcodes to be drawn on a prepared background. If this parameter is '' or 0, the current background will be used, and the module will not try change it. .PP For QRcodes, this will use the 'graybackground' color to draw a rectangle including the \*(L"quiet zone\*(R" around the QRcode. .SS "background" .IX Subsection "background" Normally it is '1 1 1', which will draw a white background/box around the barcodes. Choose another RGB-combination if you want another color. .PP For QRcodes, see 'graybackground'. .SS "rotate" .IX Subsection "rotate" A degree to rotate the barcode image counter-clockwise .SH "QRCODE SPECIFIC PARAMETERS" .IX Header "QRCODE SPECIFIC PARAMETERS" When generating QRcodes, some of the common parameters are ignored and some QRcode specific parameters are available for modifying features of the QRcode. QRcodes are generated with a Gray colorspace. .SS "graybackground" .IX Subsection "graybackground" Normally it is 1, which will draw a white background/box around the QRcodes. Choose another value between 0 and 1 (inclusive) to specify a different shade of gray for the background. .SS "modulesize" .IX Subsection "modulesize" Defaults to 1. Sets the size in Postscript points of the rectangle drawn for a single rectangle when drawing a QRcode. .SS "qr_ecc" .IX Subsection "qr_ecc" Defaults to 'M'. Sets the error correction mode for the QRcode and can be set to L (Low), M (Medium), Q (Quartile), or H (High). .SS "qr_version" .IX Subsection "qr_version" Defaults to 1. Set to an integer value from 1 to 40 to select the size and data capacity of the QRcode. .SS "qr_padding" .IX Subsection "qr_padding" Defaults to 0. Sets an amount of padding to insert between modules in the QRcode (may be useful if prints do not scan well). .SH "EXAMPLE" .IX Header "EXAMPLE" .Vb 3 \& use PDF::Reuse; \& use PDF::Reuse::Barcode; \& use strict; \& \& prFile(\*(Aqbars.pdf\*(Aq); \& \& ################################################################# \& # First a rectangle is drawn in the upper part of the page \& ################################################################# \& \& my $str = "q\en"; # save the graphic state \& $str .= "0.9 0.5 0.5 rg\en"; # a fill color \& $str .= "10 400 440 410 re\en"; # a rectangle \& $str .= "b\en"; # fill (and a little more) \& $str .= "Q\en"; # restore the graphic state \& \& prAdd($str); \& \& ################################# \& # An image with prolonged bars, \& ################################# \& \& PDF::Reuse::Barcode::ITF (x => 50, \& y => 700, \& value => \*(Aq0123456789\*(Aq, \& prolong => 2.96); \& \& ############################# \& # A magnified barcode image \& ############################# \& PDF::Reuse::Barcode::EAN13 (x => 250, \& y => 700, \& value => \*(Aq012345678901\*(Aq, \& size => 1.5); \& \& \& ###################################################### \& # A barcode image magnified a little along the y\-axis \& ###################################################### \& \& PDF::Reuse::Barcode::EAN8 (x => 150, \& y => 500, \& value => \*(Aq0123456\*(Aq, \& ySize => 1.2); \& \& ################################ \& # With the box in a light color \& ################################ \& \& PDF::Reuse::Barcode::Code39 (x => 70, \& y => 300, \& value => \*(Aq*THIS IS SOMETHING*\*(Aq, \& background => \*(Aq0.99 0.97 0.97\*(Aq, \& hide_asterisk => 1); \& \& ############################################# \& # With everything expanded along the x\-axis \& ############################################# \& \& PDF::Reuse::Barcode::NW7 (x => 70, \& y => 100, \& value => \*(Aq012345678901\*(Aq, \& xSize => 2); \& \& ################################################# \& # An image, 90 degrees rotated, might look \& # strange on the screen, should be ok as printed \& ################################################# \& \& PDF::Reuse::Barcode::UPCA (x => 400, \& y => 100, \& value => \*(Aq12345678901\*(Aq, \& drawbackground => 0, \& rotate => 90); \& \& ################################################# \& # A QRcode with a 10% gray "quiet zone" \& ################################################# \& \& PDF::Reuse::Barcode::QRcode (x => 300, \& y => 500, \& value => \*(Aqhttp://example.org/\*(Aq, \& drawbackground => 1, \& graybackground => 0.9, # 10% gray \& qr_version => 2, \& modulesize => 2); \& prEnd(); .Ve .SH "LIMITATION" .IX Header "LIMITATION" \&\s-1EAN13, EAN8, UPCA\s0 and \s-1UPCE\s0 have \*(L"guard\*(R" bars. These, a little longer bars, are often a little blurred at the lower ends when they are displayed on a screen. If you magnify the image, the lines are displayed correctly. When you print the image there shouldn't be any problem, if you use at least 600 dpi. .PP Also rotated barcodes might look strange on a screen. Most often they are much better as printed on paper. Try to use \*(L"size\*(R" rather than \*(L"prolong\*(R", when you have a rotated barcode \*(L"image\*(R". (If it has been rotated 90 or 270 degrees, you can make the bars longer with the help of xSize.) .SH "SEE ALSO" .IX Header "SEE ALSO" These modules are used for calculation of the barcode pattern .PP .Vb 10 \& Barcode::Code128 \& GD::Barcode \& GD::Barcode::Code39 \& GD::Barcode::COOP2of5 \& GD::Barcode::EAN13 \& GD::Barcode::EAN8 \& GD::Barcode::IATA2of5 \& GD::Barcode::Industrial2of5 \& GD::Barcode::ITF \& GD::Barcode::Matrix2of5 \& GD::Barcode::NW7 \& GD::Barcode::QRcode \& GD::Barcode::UPCA \& GD::Barcode::UPCE .Ve .SH "AUTHOR" .IX Header "AUTHOR" Lars Lundberg, larslund@cpan.org Chris Nighswonger, cnighs@cpan.org .SH "THANKS TO" .IX Header "THANKS TO" Everyone who has helped me with corrections and ideas, Martin Langhoff among others. And of course credits to Kawai Takanori and William R. Ward who have written the modules for calculating the barcode patterns. .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (C) 2003 \- 2009 Lars Lundberg, Solidez \s-1HB.\s0 All rights reserved. Copyright (C) 2010 \- 2014 Chris Nighswonger This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .SH "DISCLAIMER" .IX Header "DISCLAIMER" You get this module free as it is, but nothing is guaranteed to work, whatever implicitly or explicitly stated in this document, and everything you do, you do at your own risk \- I will not take responsibility for any damage, loss of money and/or health that may arise from the use of this module!