Skip to content

shuqikhor/PublicationBarcode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Barcode Generator for Publications

PHP script specifically for generating ISBN and ISSN barcodes.
It could be used to generate other EAN-13 barcodes too, though not designed to do so.

Installation

You could either download everything in src/ into your project, or install via composer:

composer require sqkhor/publication-barcode

Usage

use \SQKhor\Barcode\PublicationBarcode;

// ISBN
$barcode = new PublicationBarcode('978-967-2088-62-2');
$svg = $barcode->render('svg');

// ISBN with add on
$barcode = new PublicationBarcode('978-967-2088-62-2', '50999');
$png = $barcode->render('svg');

// ISSN with issue number
$barcode = new PublicationBarcode('3009-1004', '01');
$svg = $barcode->svg();

Method Parameters

new PublicationBarcode(code, [addon])

code (string)
The 13-digit ISBN / ISSN, or 8-digit ISSN code

addon (?string)
Supplimentary barcode data for price (ISBN) and issue number (ISSN)


render(format)

format (string)
Either one of these: svg | png | jpg | jpeg

Shorthands

$barcode = new PublicationBarcode('978-967-2088-62-2');
$svg = $barcode->svg();
$png = $barcode->png();
$jpg = $barcode->jpg();

Sample

ISBN:

ISSN with issue number:

To-Do

  • PNG / JPG render capability
  • Class parameters to set bar width & height
  • Reset after every use
  • Error handling
  • Comments / documentations
  • Tests