barcode-bakery / barcode-1d
Generates 1D barcodes from a PHP server to a file or HTML document.
Installs: 95 685
Dependents: 1
Suggesters: 0
Security: 0
Stars: 10
Watchers: 4
Forks: 2
Open Issues: 0
Requires
- php: >=7.4
- ext-gd: *
- barcode-bakery/barcode-common: >=7.0.3
This package is auto-updated.
Last update: 2024-12-16 06:47:47 UTC
README
Barcode Bakery is library written in PHP, .NET Standard and Node.JS which allows you to generate barcodes on the fly on your server for displaying or saving.
The library has minimal dependencies in each language in order to be supported on a wide variety of web servers.
The library is available for free for non-commercial use; however you must purchase a license if you plan to use it in a commercial environment.
Installation
There are two ways to install our library:
- With composer, run the following command:
composer require barcode-bakery/barcode-1d
- Or, download the library on our website, and follow our developer's guide.
Requirements
- PHP 7.4+ or PHP8
- GD2
Example usages
For a full example of how to use each symbology type, visit our API page.
Displaying a Code 128 on the screen
<?php // Path to the generated autoload file. require __DIR__ . '/../vendor/autoload.php'; use BarcodeBakery\Common\BCGFontFile; use BarcodeBakery\Common\BCGColor; use BarcodeBakery\Common\BCGDrawing; use BarcodeBakery\Barcode\BCGcode128; $font = new BCGFontFile(__DIR__ . '/font/Arial.ttf', 18); $colorBlack = new BCGColor(0, 0, 0); $colorWhite = new BCGColor(255, 255, 255); // Barcode Part $code = new BCGcode128(); $code->setScale(2); $code->setThickness(30); $code->setForegroundColor($colorBlack); $code->setBackgroundColor($colorWhite); $code->setFont($font); $code->setStart(null); $code->setTilde(true); $code->parse('a123'); // Drawing Part $drawing = new BCGDrawing($code, $colorWhite); header('Content-Type: image/png'); $drawing->finish(BCGDrawing::IMG_FORMAT_PNG);
Saving the image to a file
Replace the last lines of the previous code with the following:
// Drawing Part $drawing = new BCGDrawing($code, $colorWhite); $drawing->finish(BCGDrawing::IMG_FORMAT_PNG, 'path/to/file.png');
This will generate the following:
Supported types
- Codabar
- Code 11
- Code 128
- Code 39
- Code 39 Extended
- Code 93
- EAN-13
- EAN-8
- GS1-128 (EAN-128)
- Intelligent Mail
- Interleaved 2 of 5
- ISBN-10 / ISBN-13
- MSI Plessey
- Other (Custom)
- Postnet
- Standard 2 of 5
- UPC Extension 2
- UPC Extension 5
- UPC-A
- UPC-E