php低版本的条形码如何生成mpdf.6.0.1

网友投稿 592 2022-11-27

php低版本的条形码如何生成mpdf.6.0.1

php低版本的条形码如何生成mpdf.6.0.1

遇到一个不支持命名空间的项目 要生成条形码 当然还是用mpdf

代码

function barcode($order_id, $shipping_sn){ // Including all required classes // Loading Font $font = new BCGFontFile('../sysadm/includes/barcodegen/font/Arial.ttf', 16); // Don't forget to sanitize user inputs $text = $shipping_sn; // $text = null; // The arguments are R, G, B for color. $color_black = new BCGColor(0, 0, 0); $color_white = new BCGColor(255, 255, 255); $drawException = null; ob_clean(); try { $code = new BCGcode128(); $code->setScale(1); // Resolution $code->setThickness(35); // Thickness $code->setForegroundColor($color_black); // Color of bars $code->setBackgroundColor($color_white); // Color of spaces $code->setFont(0); // Font (or 0) $code->parse($text); // Text } catch (Exception $exception) { $drawException = $exception; } $drawing = new BCGDrawing('', $color_white); if ($drawException) { $drawing->drawException($drawException); } else { $drawing->setBarcode($code); $drawing->draw(); } header('Content-Type: image/png'); header('Content-Disposition: inline; filename="barcode.png"'); $drawing->finish(BCGDrawing::IMG_FORMAT_PNG); die;}

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:将RestTemplate的编码格式改为UTF
下一篇:php curl error code
相关文章

 发表评论

暂时没有评论,来抢沙发吧~