mPDF Manual – mPDF functions

WriteBarcode()

(mPDF >= 2.0)

mPDF – Write an EAN-13 (ISBN-13) barcode

Description

void writeBarcode ( string $code [, int $showisbn [, float $x [, float $y [, float $size [, float $border [, float $padding_left , float $padding_right , float $padding_top , float $padding_bottom ]]]]]])

Write an EAN-13 barcode. Useful information about the EAN-13 (ISBN-13) specification can be found at http://www.gs1uk.org/downloads/bar_code/Bar coding getting it right.pdf

Parameters

$code

This parameter specifies the EAN-13 (ISBN-13) code. Accepts 12 or 13 digits (i.e. with or without the check digit) and may optionally contain hyphens e.g. 978-09542-2461-5  or  978095422461

$showisbn

Specif whether to show the EAN-13 (ISBN-13) code above the barcode. NB The numbers will always appear below the bars, but the code abive the bars is optional.

Values

1 (or any positive value): show the EAN-13 code

0 zero: Hide the EAN-13 code

BLANK or omitted: 1

$x

Sets the $x (horizontal) position for the barcode.

BLANK or omitted uses the current writing position in the document.

$y

Sets the $y (vertical) position for the barcode.

BLANK or omitted uses the current writing position in the document.

$size

This parameter specifies the size of the barcode relative to the standard. Values between 0.8 and 2.0 (80% to 200%) are accepted.

DEFAULT: 1

$border

This parameter specifies whether or not to show a border around the barcode.

Values

1 or TRUE (or any positive value) will set a border

0 or FALSE or BLANK will omit the border

DEFAULT: “0” i.e. No border

$padding_left

$padding$_right

$padding$_top

$padding$_bottom$

</span>

Sets the padding around the barcode.

All values should be specified as LENGTH in millimetres

BLANK or omitted uses the default values.

DEFAULT Values

$padding$_left 1

$padding$_right 1

$padding$_top 2

$padding$_bottom 2

Changelog

VersionDescription
2.0 The function was added.

Examples

Example #1

<?php

$mpdf = new mPDF();

$mpdf->writeBarcode('978-1234-567-890');

$mpdf->Output();

?>