How to render several barcodes with Zend 2?

我的梦境 提交于 2020-01-05 07:49:22

问题


I'm trying print several barcodes using the Zend\Barcode namespace.

The problem is reading the manual I can't print more than one barcode.

I can't print a echo before the barcode too.

How can I print several barcodes and texts together?

The code I'm using is similar to this one:

use Zend\Barcode\Barcode;

$barcodeOptions = array('text' => '123456');
$rendererOptions = array();

Barcode::render(
    'code39', 'image', $barcodeOptions, $rendererOptions
);

$barcodeOptions = array('text' => '654321');
Barcode::render(
    'code39', 'image', $barcodeOptions, $rendererOptions
);

回答1:


Barcode::render() generates an image, not an HTML page with images in it. You'll need to do something like this:

barcode.php:

use Zend\Barcode\Barcode;
$barcodeOptions = array('text' => $_GET['code']);
$rendererOptions = array();
Barcode::render(
    'code39', 'image', $barcodeOptions, $rendererOptions
);

And then in your HTML, you reference that script as if it were an image:

<img src="http://domain.com/barcode.php?code=123456" />
<img src="http://domain.com/barcode.php?code=654321" />


来源:https://stackoverflow.com/questions/15882154/how-to-render-several-barcodes-with-zend-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!