如何使用Zend 2渲染多个条形码?

Gar*_*Dan 1 php zend-framework barcode barcode-printing zend-framework2

我正在尝试使用Zend \ Barcode命名空间打印几个条形码。

问题是阅读手册,我不能打印多个条形码。

我也无法在条形码之前打印回显。

如何一起打印多个条形码和文本?

我使用的代码与此类似:

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
);
Run Code Online (Sandbox Code Playgroud)

Ale*_*sky 5

Barcode::render()生成图像,而不是其中包含图像的HTML页面。您需要执行以下操作:

条码.php:

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

然后在您的HTML中,将该脚本当作图像来引用:

<img src="http://domain.com/barcode.php?code=123456" />
<img src="http://domain.com/barcode.php?code=654321" />
Run Code Online (Sandbox Code Playgroud)