飞鹅小票打印机内容超过5000字节解决方法

WPing丶

2022-04-15 11:52

<?php
    $str = "";
    for ($i=1; $i <= 100 ; $i++) {
        $str .= $i.", <L>这个是一个长订单分配打印</L><BR>";
    }
    $len = strlen($str);
    //超出5000字节分单打印
    if($len > 5000){
        $start_len = 2500;//设置在哪个位置开始分开打印
        $order_info[0] = substr($str,0,$start_len);//第一段
        $order_info[1] = substr($str,$start_len,$start_len);//第二段
        $order_info[2] = substr($str,2*$start_len);//第三段
        $brPosition1 = strpos($order_info[1],'<BR>');
        $brPosition2 = strpos($order_info[2],'<BR>');
        $s_len = $start_len+$brPosition1+4;
        $e_len = 2*$start_len+$brPosition2+4;
        $order_info[0] = substr($str,0,$s_len).'<BR><L><C>本单未打印完,接着打印下一段内容</C><C>↓↓↓↓↓↓</C></L>';
        printMsg(SN, $order_info[0],1);//第一次打印
        var_dump($order_info[0]);
        echo "\n";
        $order_info[1] = substr($str,$s_len,$e_len-$s_len);
        $order_info[2] = '<L><C>↑↑↑↑↑↑</C><C>本订单是接着打印上一段内容</C><BR>'.$order_info[1].substr($str,$e_len).'</L>';
        printMsg(SN, $order_info[2],1);
        var_dump($order_info[2]);
    }
?>


0 条评论

评论:

发送
0.104573s