Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Crazylife's avatar

Anyone facing barcode generator using milon/barcode package got issue when displaying?

I tried to generate barcode using milon/barcode package, but every first time i generate it shows me blank barcode. Anyone facing same issue as well?

echo '<img src="data:image/png;base64,' . DNS1D::getBarcodePNG("4", "C128B") . '" alt="barcode"   />';
0 likes
8 replies
toby's avatar

No issues here; I'm using this package to generate SVG barcodes which will show up in a PDF document (via barryvdh/laravel-snappy):

{!! DNS1D::getBarcodeSVG($foo->bar, "C39", 1, 25, '#2A3239') !!}
Crazylife's avatar

@toby I always having the issue during printing, the barcode always show nothing only the border, i need to close it and print again then it only will appear.

toby's avatar
toby
Best Answer
Level 31

I just tested it and inserted {!! DNS1D::getBarcodeSVG('123', "C39", 1, 25, '#2A3239') !!} in a blade file and it showed up correctly the first time. Even printing the page via ctrl+p works. Also echo '<img src="data:image/png;base64,' . DNS1D::getBarcodePNG("4", "C128B") . '" alt="barcode" />'; worked...

Does it make a difference if you change the browser?

toby's avatar

Maybe there is a CSS/JS problem..? What happens if you use a blank blade file (no CSS, no JS) and just display the barcode?

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Barcode test</title>
</head>
<body>
{!! DNS1D::getBarcodeSVG('123', "C39", 1, 25, '#2A3239') !!}
<hr>
<img src="data:image/png;base64,{{ DNS1D::getBarcodePNG("4", "C128B")}}" alt="barcode" />
</body>
</html>
toby's avatar

I tested this in Chrome, Safari and Firefox. No problems.

Crazylife's avatar

@toby I tried {!! DNS1D::getBarcodeSVG('123', "C39", 1, 25, '#2A3239') !!} , it worked for me, hehe. The last 3 params is width height and color right?

Please or to participate in this conversation.