sqkhor/publication-barcode

For generating ISBN and ISSN barcodes.

v1.0.2 2023-10-23 07:58 UTC

This package is auto-updated.

Last update: 2024-09-23 09:53:11 UTC


README

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