1

我試圖使用Zend \ Barcode命名空間打印幾個條形碼。如何使用Zend 2呈現多個條形碼?

問題是正在讀取manual我無法打印多個條形碼。

我無法在條形碼之前打印回顯。

如何一起打印多個條形碼和文本?

我正在使用的代碼是類似這樣的:

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

回答

4

Barcode::render()生成圖像,而不是HTML網頁包含圖片。你需要做這樣的事情:

barcode.php:

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

然後在你的HTML,您引用該腳本,就好像它是一個形象:

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

這項工作好的,謝謝。但是我們不能直接回應圖像嗎? – GarouDan 2013-04-08 16:37:32

+0

只有你這樣做:http://stackoverflow.com/questions/1207190/embedding-base64-images – 2013-04-08 17:08:20

+0

我認爲這是超出了我的範圍。多謝。接受=) – GarouDan 2013-04-08 17:37:55