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
Note: This function/method was altered in mPDF 2.2 by capitalising the first letter of the name. As function/method names in PHP have hitherto been case-insensitive, this should not cause any problems, but it is recommended where possible to use the preferred spelling.
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
or978095422461
- $showisbn
-
Specify whether to show the EAN-13 (ISBN-13) code above the barcode. NB The numbers will always appear below the bars, but the code above the bars is optional.
Values
1
(or any positive value): show the EAN-13 code0
(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
and2.0
(80% to 200%) are accepted.Default:
1
- $border
-
This parameter specifies whether or not to show a border around the barcode.
Values
1
ortrue
(or any positive value) will set a border0
orfalse
or BLANK will omit the border
Default:
0
i.e. No border - $padding_left
- $padding_right
- $padding_top
- $padding_bottom
-
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
- $padding_left:
Changelog
Version | Description |
---|---|
2.0 | The function was added. |
Examples
<?php
$mpdf = new \Mpdf\Mpdf();
$mpdf->writeBarcode('978-1234-567-890');
$mpdf->Output();