picqer/php-barcode-generator

Add background and margin on generated barcode

Closed this issue · 3 comments

Hello Mr @casperbakker,

I have one suggestions, because when I used Your library (very very thanks for that) we found a very big problem in our 1D scanner.

When we present barcode in dark mode (night mode) web browser change background to dark and outer lines are not readable.
image

It is possible to add param like:

$generator->setMargin(10);

$generator = new Picqer\Barcode\BarcodeGeneratorJPG();
$generator->useGd();
$generator->setMargin(10);
$result = $generator->getBarcode($inputValue, $generator::TYPE_CODE_128, 4, 120, $color = array(0, 0, 0));    
header('Content-Type: image/png');
echo $result;

or

$setMargin = 10;
$result = $generator->getBarcode($inputValue, $generator::TYPE_CODE_128, 4, 120, $color = array(0, 0, 0),$setMargin); 

Its very important issue.

Thank You

Maybe we will add something after version 3 is launched (see #198), but that will take some time.

In the mean time you can show some white border around the image with HTML/CSS, same way you show the red numbers on top.

Hi

I added in HTML/css but web browser removed this

If you added a background, that is usually ignored when printing. But a white "border" should work while printing.