如何使用Zend 2渲染多个条形码? [英] How to render several barcodes with Zend 2?

查看:73
本文介绍了如何使用Zend 2渲染多个条形码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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
);

推荐答案

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

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

barcode.php:

barcode.php:

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

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

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" />

这篇关于如何使用Zend 2渲染多个条形码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆