PHP如何在2列zebra prn代码中打印条形码

时间:2017-08-06 07:21:16

标签: php

我陷入编码困境,无法获得解决方案。我有PHP代码,使用prn代码在zebraGC420T打印机中打印条形码。我也附上了prn文件。一切都工作正常,但每张印刷品都会得到双重打印。

例如,如果我必须打印2个标签,它将打印4个标签,如果我需要打印4个标签,它将有16个标签。我知道一些我必须添加逻辑的地方,所以我需要你的建议来完成代码,请帮助我。

foreach ($barcodes as $item) {
    for ($r = 1; $r <= $item['quantity']; $r++) {

        $p = $item['quantity'];
        echo $p;

        //Label First///                                        
        $label .= "N\n";
        $label .= "A580,175,2,2,2,2,N,"."'.$item[site].'\n";
        $label .= "B586,68,2,1,2,6,40,B,"."'.$item[name].'\n";
        $label .= "A590,137,2,4,1,1,N,"."'.$item[name].'\n";                                        
        $label .= "A599,102,2,4,1,1,N,"."MRP\n";
        $label .= "A550,113,2,3,2,2,N,"."'.$item[price].'\n";

        //Label Second///
        $label .= "A275,175,2,2,2,2,N,"."'.$item[site].'\n";
        $label .= "B281,68,2,1,2,6,40,B,"."'.$item[name].'\n";
        $label .= "A285,137,2,4,1,1,N,"."'.$item[name].'\n";
        $label .= "A294,102,2,4,1,1,N,"."MRP\n";
        $label .= "A245,113,2,3,2,2,N,"."'.$item[price].'\n";
        $label .= "P1\n";
        $label .= '\n';
    }
$r++

条形码设计示例 - https://www.dhresource.com/webp/m/0x0s/f2-albu-g3-M00-E4-05-rBVaHFYzWP-ABP9XAACXAOlRpWk369.jpg/glossy-white-pet-label-sticker-35mm-x-8mm.jpg

这是我打印文件并使用dos命令将其发送到条形码打印机的方式,一切都很好,只是没有打印正确的nos ..

$current = file_get_contents($file);
$label  = "Q203,024\n";
$label .= "q831\n";
$label .= "rN\n";
$label .= "S5\n";
$label .= "D10\n";
$label .= "ZT\n";
$label .= "JF\n";
$label .= "O\n";
$label .= "R109,0\n";
$label .= "f100\n";
$label .= "N\n";
$label .= "A580,175,2,2,2,2,N,"."'POSSHINE'\n";
$label .= "B586,68,2,1,2,6,40,B,"."'1234567'\n";
$label .= "A590,137,2,4,1,1,N,"."'Lee Jeans'\n";
$label .= "A599,102,2,4,1,1,N,"."MRP\n";
$label .= "A550,113,2,3,2,2,N,"."'Rs.899'\n";
$label .= "A275,175,2,2,2,2,N,"."'Posshine'\n";
$label .= "B281,68,2,1,2,6,40,B,"."'1234567'\n";
$label .= "A285,137,2,4,1,1,N,"."'Lee Jeans'\n";
$label .= "A294,102,2,4,1,1,N,"."MRP\n";
$label .= "A245,113,2,3,2,2,N,"."'Rs.899'\n";
$label .= "P1\n";
$label .= '\n';
$current = $label;
file_put_contents($file, $current."\n", FILE_APPEND);

0 个答案:

没有答案