Initial import
This commit is contained in:
2861
one-api/vendor/picqer/php-barcode-generator/src/BarcodeGenerator.php
vendored
Normal file
2861
one-api/vendor/picqer/php-barcode-generator/src/BarcodeGenerator.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
43
one-api/vendor/picqer/php-barcode-generator/src/BarcodeGeneratorHTML.php
vendored
Normal file
43
one-api/vendor/picqer/php-barcode-generator/src/BarcodeGeneratorHTML.php
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Picqer\Barcode;
|
||||
|
||||
class BarcodeGeneratorHTML extends BarcodeGenerator
|
||||
{
|
||||
|
||||
/**
|
||||
* Return an HTML representation of barcode.
|
||||
*
|
||||
* @param string $code code to print
|
||||
* @param string $type type of barcode
|
||||
* @param int $widthFactor Width of a single bar element in pixels.
|
||||
* @param int $totalHeight Height of a single bar element in pixels.
|
||||
* @param int|string $color Foreground color for bar elements (background is transparent).
|
||||
* @return string HTML code.
|
||||
* @public
|
||||
*/
|
||||
public function getBarcode($code, $type, $widthFactor = 2, $totalHeight = 30, $color = 'black')
|
||||
{
|
||||
$barcodeData = $this->getBarcodeData($code, $type);
|
||||
|
||||
$html = '<div style="font-size:0;position:relative;width:' . ($barcodeData['maxWidth'] * $widthFactor) . 'px;height:' . ($totalHeight) . 'px;">' . "\n";
|
||||
|
||||
$positionHorizontal = 0;
|
||||
foreach ($barcodeData['bars'] as $bar) {
|
||||
$barWidth = round(($bar['width'] * $widthFactor), 3);
|
||||
$barHeight = round(($bar['height'] * $totalHeight / $barcodeData['maxHeight']), 3);
|
||||
|
||||
if ($bar['drawBar']) {
|
||||
$positionVertical = round(($bar['positionVertical'] * $totalHeight / $barcodeData['maxHeight']), 3);
|
||||
// draw a vertical bar
|
||||
$html .= '<div style="background-color:' . $color . ';width:' . $barWidth . 'px;height:' . $barHeight . 'px;position:absolute;left:' . $positionHorizontal . 'px;top:' . $positionVertical . 'px;"> </div>' . "\n";
|
||||
}
|
||||
|
||||
$positionHorizontal += $barWidth;
|
||||
}
|
||||
|
||||
$html .= '</div>' . "\n";
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
77
one-api/vendor/picqer/php-barcode-generator/src/BarcodeGeneratorJPG.php
vendored
Normal file
77
one-api/vendor/picqer/php-barcode-generator/src/BarcodeGeneratorJPG.php
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace Picqer\Barcode;
|
||||
|
||||
use Picqer\Barcode\Exceptions\BarcodeException;
|
||||
|
||||
class BarcodeGeneratorJPG extends BarcodeGenerator
|
||||
{
|
||||
|
||||
/**
|
||||
* Return a JPG image representation of barcode (requires GD or Imagick library).
|
||||
*
|
||||
* @param string $code code to print
|
||||
* @param string $type type of barcode:
|
||||
* @param int $widthFactor Width of a single bar element in pixels.
|
||||
* @param int $totalHeight Height of a single bar element in pixels.
|
||||
* @param array $color RGB (0-255) foreground color for bar elements (background is transparent).
|
||||
* @return string image data or false in case of error.
|
||||
* @public
|
||||
* @throws BarcodeException
|
||||
*/
|
||||
public function getBarcode($code, $type, $widthFactor = 2, $totalHeight = 30, $color = array(0, 0, 0))
|
||||
{
|
||||
$barcodeData = $this->getBarcodeData($code, $type);
|
||||
|
||||
// calculate image size
|
||||
$width = ($barcodeData['maxWidth'] * $widthFactor);
|
||||
$height = $totalHeight;
|
||||
|
||||
if (function_exists('imagecreate')) {
|
||||
// GD library
|
||||
$imagick = false;
|
||||
$jpg = imagecreate($width, $height);
|
||||
$colorBackground = imagecolorallocate($jpg, 255, 255, 255);
|
||||
imagecolortransparent($jpg, $colorBackground);
|
||||
$colorForeground = imagecolorallocate($jpg, $color[0], $color[1], $color[2]);
|
||||
} elseif (extension_loaded('imagick')) {
|
||||
$imagick = true;
|
||||
$colorForeground = new \imagickpixel('rgb(' . $color[0] . ',' . $color[1] . ',' . $color[2] . ')');
|
||||
$jpg = new \Imagick();
|
||||
$jpg->newImage($width, $height, 'white', 'jpg');
|
||||
$imageMagickObject = new \imagickdraw();
|
||||
$imageMagickObject->setFillColor($colorForeground);
|
||||
} else {
|
||||
throw new BarcodeException('Neither gd-lib or imagick are installed!');
|
||||
}
|
||||
|
||||
// print bars
|
||||
$positionHorizontal = 0;
|
||||
foreach ($barcodeData['bars'] as $bar) {
|
||||
$bw = round(($bar['width'] * $widthFactor), 3);
|
||||
$bh = round(($bar['height'] * $totalHeight / $barcodeData['maxHeight']), 3);
|
||||
if ($bar['drawBar']) {
|
||||
$y = round(($bar['positionVertical'] * $totalHeight / $barcodeData['maxHeight']), 3);
|
||||
// draw a vertical bar
|
||||
if ($imagick && isset($imageMagickObject)) {
|
||||
$imageMagickObject->rectangle($positionHorizontal, $y, ($positionHorizontal + $bw), ($y + $bh));
|
||||
} else {
|
||||
imagefilledrectangle($jpg, $positionHorizontal, $y, ($positionHorizontal + $bw) - 1, ($y + $bh),
|
||||
$colorForeground);
|
||||
}
|
||||
}
|
||||
$positionHorizontal += $bw;
|
||||
}
|
||||
ob_start();
|
||||
if ($imagick && isset($imageMagickObject)) {
|
||||
$jpg->drawImage($imageMagickObject);
|
||||
echo $jpg;
|
||||
} else {
|
||||
imagejpeg($jpg);
|
||||
imagedestroy($jpg);
|
||||
}
|
||||
$image = ob_get_clean();
|
||||
|
||||
return $image;
|
||||
}
|
||||
}
|
||||
76
one-api/vendor/picqer/php-barcode-generator/src/BarcodeGeneratorPNG.php
vendored
Normal file
76
one-api/vendor/picqer/php-barcode-generator/src/BarcodeGeneratorPNG.php
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace Picqer\Barcode;
|
||||
|
||||
use Picqer\Barcode\Exceptions\BarcodeException;
|
||||
|
||||
class BarcodeGeneratorPNG extends BarcodeGenerator
|
||||
{
|
||||
|
||||
/**
|
||||
* Return a PNG image representation of barcode (requires GD or Imagick library).
|
||||
*
|
||||
* @param string $code code to print
|
||||
* @param string $type type of barcode:
|
||||
* @param int $widthFactor Width of a single bar element in pixels.
|
||||
* @param int $totalHeight Height of a single bar element in pixels.
|
||||
* @param array $color RGB (0-255) foreground color for bar elements (background is transparent).
|
||||
* @return string image data or false in case of error.
|
||||
* @public
|
||||
*/
|
||||
public function getBarcode($code, $type, $widthFactor = 2, $totalHeight = 30, $color = array(0, 0, 0))
|
||||
{
|
||||
$barcodeData = $this->getBarcodeData($code, $type);
|
||||
|
||||
// calculate image size
|
||||
$width = ($barcodeData['maxWidth'] * $widthFactor);
|
||||
$height = $totalHeight;
|
||||
|
||||
if (function_exists('imagecreate')) {
|
||||
// GD library
|
||||
$imagick = false;
|
||||
$png = imagecreate($width, $height);
|
||||
$colorBackground = imagecolorallocate($png, 255, 255, 255);
|
||||
imagecolortransparent($png, $colorBackground);
|
||||
$colorForeground = imagecolorallocate($png, $color[0], $color[1], $color[2]);
|
||||
} elseif (extension_loaded('imagick')) {
|
||||
$imagick = true;
|
||||
$colorForeground = new \imagickpixel('rgb(' . $color[0] . ',' . $color[1] . ',' . $color[2] . ')');
|
||||
$png = new \Imagick();
|
||||
$png->newImage($width, $height, 'none', 'png');
|
||||
$imageMagickObject = new \imagickdraw();
|
||||
$imageMagickObject->setFillColor($colorForeground);
|
||||
} else {
|
||||
throw new BarcodeException('Neither gd-lib or imagick are installed!');
|
||||
}
|
||||
|
||||
// print bars
|
||||
$positionHorizontal = 0;
|
||||
foreach ($barcodeData['bars'] as $bar) {
|
||||
$bw = round(($bar['width'] * $widthFactor), 3);
|
||||
$bh = round(($bar['height'] * $totalHeight / $barcodeData['maxHeight']), 3);
|
||||
if ($bar['drawBar']) {
|
||||
$y = round(($bar['positionVertical'] * $totalHeight / $barcodeData['maxHeight']), 3);
|
||||
// draw a vertical bar
|
||||
if ($imagick && isset($imageMagickObject)) {
|
||||
$imageMagickObject->rectangle($positionHorizontal, $y, ($positionHorizontal + $bw), ($y + $bh));
|
||||
} else {
|
||||
imagefilledrectangle($png, $positionHorizontal, $y, ($positionHorizontal + $bw) - 1, ($y + $bh),
|
||||
$colorForeground);
|
||||
}
|
||||
}
|
||||
$positionHorizontal += $bw;
|
||||
}
|
||||
ob_start();
|
||||
if ($imagick && isset($imageMagickObject)) {
|
||||
$png->drawImage($imageMagickObject);
|
||||
echo $png;
|
||||
} else {
|
||||
imagepng($png);
|
||||
imagedestroy($png);
|
||||
}
|
||||
$image = ob_get_clean();
|
||||
|
||||
return $image;
|
||||
}
|
||||
}
|
||||
50
one-api/vendor/picqer/php-barcode-generator/src/BarcodeGeneratorSVG.php
vendored
Normal file
50
one-api/vendor/picqer/php-barcode-generator/src/BarcodeGeneratorSVG.php
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Picqer\Barcode;
|
||||
|
||||
class BarcodeGeneratorSVG extends BarcodeGenerator
|
||||
{
|
||||
|
||||
/**
|
||||
* Return a SVG string representation of barcode.
|
||||
*
|
||||
* @param $code (string) code to print
|
||||
* @param $type (const) type of barcode
|
||||
* @param $widthFactor (int) Minimum width of a single bar in user units.
|
||||
* @param $totalHeight (int) Height of barcode in user units.
|
||||
* @param $color (string) Foreground color (in SVG format) for bar elements (background is transparent).
|
||||
* @return string SVG code.
|
||||
* @public
|
||||
*/
|
||||
public function getBarcode($code, $type, $widthFactor = 2, $totalHeight = 30, $color = 'black')
|
||||
{
|
||||
$barcodeData = $this->getBarcodeData($code, $type);
|
||||
|
||||
// replace table for special characters
|
||||
$repstr = array("\0" => '', '&' => '&', '<' => '<', '>' => '>');
|
||||
|
||||
$width = round(($barcodeData['maxWidth'] * $widthFactor), 3);
|
||||
|
||||
$svg = '<?xml version="1.0" standalone="no" ?>' . "\n";
|
||||
$svg .= '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">' . "\n";
|
||||
$svg .= '<svg width="' . $width . '" height="' . $totalHeight . '" viewBox="0 0 ' . $width . ' ' . $totalHeight . '" version="1.1" xmlns="http://www.w3.org/2000/svg">' . "\n";
|
||||
$svg .= "\t" . '<desc>' . strtr($barcodeData['code'], $repstr) . '</desc>' . "\n";
|
||||
$svg .= "\t" . '<g id="bars" fill="' . $color . '" stroke="none">' . "\n";
|
||||
// print bars
|
||||
$positionHorizontal = 0;
|
||||
foreach ($barcodeData['bars'] as $bar) {
|
||||
$barWidth = round(($bar['width'] * $widthFactor), 3);
|
||||
$barHeight = round(($bar['height'] * $totalHeight / $barcodeData['maxHeight']), 3);
|
||||
if ($bar['drawBar']) {
|
||||
$positionVertical = round(($bar['positionVertical'] * $totalHeight / $barcodeData['maxHeight']), 3);
|
||||
// draw a vertical bar
|
||||
$svg .= "\t\t" . '<rect x="' . $positionHorizontal . '" y="' . $positionVertical . '" width="' . $barWidth . '" height="' . $barHeight . '" />' . "\n";
|
||||
}
|
||||
$positionHorizontal += $barWidth;
|
||||
}
|
||||
$svg .= "\t" . '</g>' . "\n";
|
||||
$svg .= '</svg>' . "\n";
|
||||
|
||||
return $svg;
|
||||
}
|
||||
}
|
||||
5
one-api/vendor/picqer/php-barcode-generator/src/Exceptions/BarcodeException.php
vendored
Normal file
5
one-api/vendor/picqer/php-barcode-generator/src/Exceptions/BarcodeException.php
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Picqer\Barcode\Exceptions;
|
||||
|
||||
class BarcodeException extends \Exception {}
|
||||
5
one-api/vendor/picqer/php-barcode-generator/src/Exceptions/InvalidCharacterException.php
vendored
Normal file
5
one-api/vendor/picqer/php-barcode-generator/src/Exceptions/InvalidCharacterException.php
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Picqer\Barcode\Exceptions;
|
||||
|
||||
class InvalidCharacterException extends BarcodeException {}
|
||||
5
one-api/vendor/picqer/php-barcode-generator/src/Exceptions/InvalidCheckDigitException.php
vendored
Normal file
5
one-api/vendor/picqer/php-barcode-generator/src/Exceptions/InvalidCheckDigitException.php
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Picqer\Barcode\Exceptions;
|
||||
|
||||
class InvalidCheckDigitException extends BarcodeException {}
|
||||
5
one-api/vendor/picqer/php-barcode-generator/src/Exceptions/InvalidFormatException.php
vendored
Normal file
5
one-api/vendor/picqer/php-barcode-generator/src/Exceptions/InvalidFormatException.php
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Picqer\Barcode\Exceptions;
|
||||
|
||||
class InvalidFormatException extends BarcodeException {}
|
||||
5
one-api/vendor/picqer/php-barcode-generator/src/Exceptions/InvalidLengthException.php
vendored
Normal file
5
one-api/vendor/picqer/php-barcode-generator/src/Exceptions/InvalidLengthException.php
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Picqer\Barcode\Exceptions;
|
||||
|
||||
class InvalidLengthException extends BarcodeException {}
|
||||
5
one-api/vendor/picqer/php-barcode-generator/src/Exceptions/UnknownTypeException.php
vendored
Normal file
5
one-api/vendor/picqer/php-barcode-generator/src/Exceptions/UnknownTypeException.php
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Picqer\Barcode\Exceptions;
|
||||
|
||||
class UnknownTypeException extends BarcodeException {}
|
||||
Reference in New Issue
Block a user