{
    "content": [
        {
            "type": "text",
            "text": "# Barcode::Code128 (perldoc)\n\n## NAME\n\nBarcode::Code128 - Generate CODE 128 bar codes\n\n## SYNOPSIS\n\nuse Barcode::Code128;\n$code = new Barcode::Code128;\n\n## DESCRIPTION\n\nBarcode::Code128 generates bar codes using the CODE 128 symbology. It can generate images in PNG\nor GIF format using the GD package, or it can generate a text string representing the barcode\nthat you can render using some other technology if desired.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **REQUIRES**\n- **EXPORTS**\n- **DESCRIPTION**\n- **METHODS** (1 subsections)\n- **CLASS VARIABLES**\n- **DIAGNOSTICS**\n- **BUGS**\n- **AUTHOR**\n- **SEE ALSO** (1 subsections)\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Barcode::Code128",
        "section": "",
        "mode": "perldoc",
        "summary": "Barcode::Code128 - Generate CODE 128 bar codes",
        "synopsis": "use Barcode::Code128;\n$code = new Barcode::Code128;",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "REQUIRES",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "EXPORTS",
                "lines": 26,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 35,
                "subsections": []
            },
            {
                "name": "METHODS",
                "lines": 111,
                "subsections": [
                    {
                        "name": "Housekeeping Functions",
                        "lines": 58
                    }
                ]
            },
            {
                "name": "CLASS VARIABLES",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DIAGNOSTICS",
                "lines": 84,
                "subsections": []
            },
            {
                "name": "BUGS",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 1,
                "subsections": [
                    {
                        "name": "perl",
                        "lines": 1
                    }
                ]
            }
        ],
        "sections": {
            "NAME": {
                "content": "Barcode::Code128 - Generate CODE 128 bar codes\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use Barcode::Code128;\n\n$code = new Barcode::Code128;\n",
                "subsections": []
            },
            "REQUIRES": {
                "content": "Perl 5.004, Carp, Exporter, GD (optional)\n",
                "subsections": []
            },
            "EXPORTS": {
                "content": "By default, nothing. However there are a number of constants that represent special characters\nused in the CODE 128 symbology that you may wish to include. For example if you are using the\nEAN-128 or UCC-128 code, the string to encode begins with the FNC1 character. To encode the\nEAN-128 string \"00 0 0012345 555555555 8\", you would do the following:\n\nuse Barcode::Code128 'FNC1';\n$code = new Barcode::Code128;\n$code->text(FNC1.'00000123455555555558');\n\nTo have this module export one or more of these characters, specify them on the \"use\" statement\nor use the special token ':all' instead to include all of them. Examples:\n\nuse Barcode::Code128 qw(FNC1 FNC2 FNC3 FNC4 Shift);\nuse Barcode::Code128 qw(:all);\n\nHere is the complete list of the exportable characters. They are assigned to high-order ASCII\ncharacters purely arbitrarily for the purposes of this module; the values used do not reflect\nany part of the CODE 128 standard. Warning: Using the \"CodeA\", \"CodeB\", \"CodeC\", \"StartA\",\n\"StartB\", \"StartC\", and \"Stop\" codes may cause your barcodes to be invalid, and be rejected by\nscanners. They are inserted automatically as needed by this module.\n\nCodeA      0xf4        CodeB      0xf5         CodeC      0xf6\nFNC1       0xf7        FNC2       0xf8         FNC3       0xf9\nFNC4       0xfa        Shift      0xfb         StartA     0xfc\nStartB     0xfd        StartC     0xfe         Stop       0xff\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "Barcode::Code128 generates bar codes using the CODE 128 symbology. It can generate images in PNG\nor GIF format using the GD package, or it can generate a text string representing the barcode\nthat you can render using some other technology if desired.\n\nThe intended use of this module is to create a web page with a bar code on it, which can then be\nprinted out and faxed or mailed to someone who will scan the bar code. The application which\nspurred its creation was an expense report tool, where the employee submitting the report would\nprint out the web page and staple the receipts to it, and the Accounts Payable clerk would scan\nthe bar code to indicate that the receipts were received.\n\nThe default settings for this module produce a large image that can safely be FAXed several\ntimes and still scanned easily. If this requirement is not important you can generate smaller\nimage using optional parameters, described below.\n\nIf you wish to generate images with this module you must also have the GD module (written by\nLincoln Stein, and available from CPAN) installed. Using the libgd library, GD can generate\nfiles in PNG (Portable Network Graphics) or GIF (Graphic Interchange Format) formats.\n\nStarting with version 1.20, and ending with 2.0.28 (released July 21st, 2004), GD and the\nunderlying libgd library could not generate GIF files due to patent issues, but any modern\nversion of libgd (since 2004) can do GIF as the patent has expired. Most browsers have no\ntrouble with PNG files.\n\nIn order to ensure you have a sufficiently modern installation of the GD module to do both GIF\nand PNG formats, we require version 2.18 of GD (which in turn requires libgd 2.0.28) or higher.\n\nIf the GD module is not present, you can still use the module, but you will not be able to use\nits functions for generating images. You can use the barcode() method to get a string of \"#\" and\n\" \" (hash and space) characters, and use your own image-generating routine with that as input.\n\nTo use the the GD module, you will need to install it along with this module. You can obtain it\nfrom the CPAN (Comprehensive Perl Archive Network) repository of your choice under the directory\n\"authors/id/LDS\". Visit http://www.cpan.org/ for more information about CPAN. The GD home page\nis: http://stein.cshl.org/WWW/software/GD/GD.html\n",
                "subsections": []
            },
            "METHODS": {
                "content": "new Usage:\n\n$object = new Barcode::Code128\n\nCreates a new barcode object.\n\noption\nSets or retreives various options. If called with only one parameter, retrieves the value\nfor that parameter. If called with more than one parameter, treats the parameters as\nname/value pairs and sets those option values accordingly. If called with no parameters,\nreturns a hash consisting of the values of all the options (hash ref in scalar context).\nWhen an option has not been set, its default value is returned.\n\nYou can also set or retrieve any of these options by using it as a method name. For example,\nto set the value of the padding option, you can use either of these:\n\n$barcode->padding(10);\n$barcode->option(\"padding\", 10);\n\nThe valid options, and the default value and meaning of each, are:\n\nwidth            undef    Width of the image (*)\nheight           undef    Height of the image (*)\nborder           2        Size of the black border around the barcode\nscale            2        How many pixels for the smallest barcode stripe\nfont             \"large\"  Font () for the text at the bottom\nshowtext        1        True/False: display the text at the bottom?\nfontmargin      2        Pixels above, below, and to left of the text\nfontalign       \"left\"   Align the text (\"left\", \"right\", or \"center\")\ntransparenttext 1/0(*) True/False: use transparent background for text?\ntopmargin       0        No. of pixels above the barcode\nbottommargin    0        No. of pixels below the barcode (& text)\nleftmargin      0        No. of pixels to the left of the barcode\nrightmargin     0        No. of pixels to the right of the barcode\npadding          20       Size of whitespace before & after barcode\n\n* Width and height are the default values for the $x and $y arguments to the png, gif, or\ngdimage method (q.v.)\n\nFont may be one of the following: \"giant\", \"large\", \"medium\", \"small\", or \"tiny\". Or, it\nmay be any valid GD font name, such as \"gdMediumFont\".\n\n* The \"transparenttext\" option is \"1\" (true) by default for GIF output, but \"0\" (false)\nfor PNG. This is because PNG transparency is not supported well by many viewing software The\nbackground color is grey (#CCCCCC) when not transparent.\n\ngif\npng\ngdimage\nUsage:\n\n$object->png($text)\n$object->png($text, $x, $y)\n$object->png($text, { options... })\n\n$object->gif($text)\n$object->gif($text, $x, $y)\n$object->gif($text, { options... })\n\n$object->gdimage($text)\n$object->gdimage($text, $x, $y)\n$object->gdimage($text, { options... })\n\nThese methods generate an image using the GD module. The gdimage() method returns a GD\nobject, which is useful if you want to do additional processing to it using the GD object\nmethods. The other two create actual images. NOTE: GIF files require an old version of GD,\nand so you probably are not able to create them - see below.\n\nThe gif() and png() methods are wrappers around gdimage() that create the GD object and\nthen run the corresponding GD method to create output that can be displayed or saved to a\nfile. Note that only one of these two methods will work, depending on which version of GD\nyou have - see below. The return value from gif() or png() is a binary file, so if you are\nworking on an operating system (e.g. Microsoft Windows) that makes a distinction between\ntext and binary files be sure to call binmode(FILEHANDLE) before writing the image to it, or\nthe file may get corrupted. Example:\n\nopen(PNG, \">code128.png\") or die \"Can't write code128.png: $!\\n\";\nbinmode(PNG);\nprint PNG $object->png(\"CODE 128\");\nclose(PNG);\n\nIf you have GD version 1.20 or newer, the PNG file format is the only allowed option.\nConversely if you have GD version prior to 1.20, then the GIF format is the only option.\nCheck the $object->imageformat() method to find out which you have (q.v.).\n\nNote: All of the arguments to this function are optional. If you have previously specified\n$text to the \"barcode()\", \"encode()\", or \"text()\" methods, you do not need to specify it\nagain. The $x and $y variables specify the size of the barcode within the image in pixels.\nIf size(s) are not specified, they will be set to the minimum size, which is the length of\nthe barcode plus 40 pixels horizontally, and 15% of the length of the barcode vertically.\nSee also the $object->width() and $object->height() methods for another way of specifying\nthis.\n\nIf instead of specifying $x and $y, you pass a reference to a hash of name/value pairs,\nthese will be used as the options, overriding anything set using the $object->option() (or\nwidth/height) method (q.v.). However, this will not set the options so any future barcodes\nusing the same object will revert to the option list of the object. If you want to set the\noptions permanently use the option, width, and/or height methods instead.\n\nbarcode\nUsage:\n\n$object->barcode($text)\n\nComputes the bar code for the specified text. The result will be a string of '#' and space\ncharacters representing the dark and light bands of the bar code. You can use this if you\nhave an alternate printing system besides using GD to create the images.\n\nNote: The $text parameter is optional. If you have previously specified $text to the\n\"encode()\" or \"text()\" methods, you do not need to specify it again.\n",
                "subsections": [
                    {
                        "name": "Housekeeping Functions",
                        "content": "The rest of the methods defined here are only for internal use, or if you really know what you\nare doing. Some of them may be useful to authors of classes that inherit from this one, or may\nbe overridden by subclasses. If you just want to use this module to generate bar codes, you can\nstop reading here.\n\nencode\nUsage:\n\n$object->encode\n$object->encode($text)\n$object->encode($text, $preferredcode)\n\nDo the encoding. If $text is supplied, will automatically call the text() method to set that\nas the text value first. If $preferredcode is supplied, will try that code first.\nOtherwise, the codes will be tried in the following manner:\n\n1. If it is possible to use Code C for any of the text, use that for as much of it as\npossible.\n\n2. Check how many characters would be converted using codes A or B, and use that code to\nconvert them. If the amount is equal, code A is used.\n\n3. Repeat steps 1 and 2 until the text string has been completely encoded.\n\ntext\nUsage:\n\n$object->text($text)\n$text = $object->text\n\nSet or retrieve the text for this barcode. This will be called automatically by encode() or\nbarcode() so typically this will not be used directly by the user.\n\nstart\nUsage:\n\n$object->start($code)\n\nIf the code (see code()) is already defined, then adds the CodeA, CodeB, or CodeC character\nas appropriate to the encoded message inside the object. Typically for internal use only.\n\nstop\nUsage:\n\n$object->stop()\n\nComputes the check character and appends it along with the Stop character, to the encoded\nstring. Typically for internal use only.\n\ncode\nUsage:\n\n$object->code($code)\n$code = $object->code\n\nSet or retrieve the code for this barcode. $code may be 'A', 'B', or 'C'. Typically for\ninternal use only. Not particularly meaningful unless called during the middle of encoding.\n"
                    }
                ]
            },
            "CLASS VARIABLES": {
                "content": "None.\n",
                "subsections": []
            },
            "DIAGNOSTICS": {
                "content": "Unrecognized option ($opt) for $class\nThe specified option is not valid for the module. $class should be \"Barcode::Code128\" but if\nit has been inherited into another module, that module will show instead. $opt is the\nattempted option.\n\nThe gdimage() method of Barcode::Code128 requires the GD module\nTo call the \"gdimage()\", \"png()\", or \"gif()\" methods, the GD module must be present. This\nmodule is used to create the actual image. Without it, you can only use the \"barcode()\"\nmethod.\n\nScale must be a positive integer\nThe scale factor for the \"gdimage()\", \"png()\", or \"gif()\" methods must be a positive\ninteger.\n\nBorder ($border) must be a positive integer or zero\nThe border option cannot be a fractional or negative number.\n\nInvalid font $font\nThe specified font is not valid. Note that this is tested using GD->can(), and so any\nsubroutine in GD.pm will pass this test - but only the fonts will actually work. See the GD\nmodule documentation for more.\n\nImage width $x is too small for bar code\nYou have specified an image width that does not allow enough space for the bar code to be\ndisplayed. The minimum allowable is the size of the bar code itself plus 40 pixels. If in\ndoubt, just omit the width value when calling \"gdimage()\", \"png()\", or \"gif()\" and it will\nuse the minimum.\n\nImage height $y is too small for bar code\nYou have specified an image height that does not allow enough space for the bar code to be\ndisplayed. The minimum allowable is 15% of the width of the bar code. If in doubt, just omit\nthe height value when calling \"gdimage()\", \"png()\", or \"gif()\" and it will use the minimum.\n\nUnable to create $x x $y image\nAn error occurred when initializing a GD::Image object for the specified size. Perhaps $x\nand $y are too large for memory?\n\nThe gif() method of Barcode::Code128 requires the GD module\nThe gif() method of Barcode::Code128 requires version less than 1.20 of GD\nThe png() method of Barcode::Code128 requires the GD module\nThe png() method of Barcode::Code128 requires at least version 1.20 of GD\nThese errors indicate that the GD module, or the correct version of the GD module for this\nmethod, was not present. You need to install GD version 1.20 or greater to create PNG files,\nor a version of GD less than 1.20 to create GIF files.\n\nNo encoded text found\nThis message from \"barcode()\" typically means that there was no text message supplied either\nduring the current method call or in a previous method call on the same object. This error\noccurs when you are trying to create a barcode by calling one of \"gdimage()\", \"png()\",\n\"gif()\", or \"barcode()\" without having specified the text to be encoded.\n\nNo text defined\nThis message from \"encode()\" typically means that there was no text message supplied either\nduring the current method call or in a previous method call on the same object.\n\nInvalid preferred code ``$preferredcode''\nThis error means \"encode()\" was called with the $preferredcode optional parameter but it\nwas not one of ``A'', ``B'', or ``C''.\n\nSanity Check Overflow\nThis is a serious error in \"encode()\" that indicates a serious problem attempting to encode\nthe requested message. This means that an infinite loop was generated. If you get this error\nplease contact the author.\n\nUnable to find encoding for ``$text''\nPart or all of the message could not be encoded. This may mean that the message contained\ncharacters not encodable in the CODE 128 character set, such as a character with an ASCII\nvalue higher than 127 (except the special control characters defined in this module).\n\nUnable to switch from ``$oldcode'' to ``$newcode''\nThis is a serious error in \"start()\" that indicates a serious problem occurred when\nswitching between the codes (A, B, or C) of CODE 128. If you get this error please contact\nthe author.\n\nUnable to start with ``$newcode''\nThis is a serious error in \"start()\" that indicates a serious problem occurred when starting\nencoding in one of the codes (A, B, or C) of CODE 128. If you get this error please contact\nthe author.\n\nUnknown code ``$newcode'' (should be A, B, or C)\nThis is a serious error in \"code()\" that indicates an invalid argument was supplied. Only\nthe codes (A, B, or C) of CODE 128 may be supplied here. If you get this error please\ncontact the author.\n",
                "subsections": []
            },
            "BUGS": {
                "content": "At least some Web browsers do not seem to handle PNG files with transparent backgrounds\ncorrectly. As a result, the default for PNG is to generate barcodes without transparent\nbackgrounds - the background is grey instead.\n",
                "subsections": []
            },
            "AUTHOR": {
                "content": "William R. Ward, wrw@bayview.com\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "",
                "subsections": [
                    {
                        "name": "perl",
                        "content": ""
                    }
                ]
            }
        }
    }
}