laravel条形码 二维码 生成

  1. composer require milon/barcode 5.3

class CodeController extends Controller
{
//
public function yicode(Request $request){
$cc = new DNS1D();
i m g = " d a t a : i m a g e / p n g ; b a s e 64 , " . img = "data:image/png;base64,". cc->getBarcodePNG( r e q u e s t > n u m , request->num, request->type);
return $img;
}
}
num为传入的号码 ,type为条形码类型

PS:http://www.luohun.org/index.php/archives/33/

https://laravel-china.org/index.php/courses/laravel-package/bar-code-generation-tool-milonbarcode/2037

http://www.luohun.org/index.php/archives/33/#comment-27

PLAN B:

use Milon\Barcode\DNS1D;

class BarcodeController extends Controller
{
//生成条形码
public function index(Request $request){
$cc = new DNS1D();
t i t l e = s u b s t r ( title = substr( request->title,0,14); //截取title长度
for( i = 0 ; i=0; i<44;$i++){
// a r r = [ 1 , 5 , 9 , 13 , 17 , 21 , 25 , 29 , 33 , 37 , 41 ] ; i f ( arr = [1,5,9,13,17,21,25,29,33,37,41]; if( i%4==0|| i e c h o &lt; d i v s t y l e = &quot; w i d t h : 155 p x ; f l o a t : r i g h t ; m a r g i n : 1 p x 017 p x 8 p x ; p a d d i n g l e f t : 3 p x &quot; &gt; &lt; d i v &gt; &lt; i m g s t y l e = &quot; w i d t h : a u t o ; m a x w i d t h : 95 i%3==0){ echo &#x27;&lt;div style=&quot;width: 155px; float: right;margin:1px 0 17px 8px;padding-left: 3px&quot;&gt;&lt;div&gt;&lt;img style=&quot;width: auto;max-width: 95%&quot; src=&quot;data:image/png;base64,&#x27; . cc->getBarcodePNG($request->num, r e q u e s t &gt; t y p e ) . &quot; a l t = &quot; b a r c o d e &quot; / &gt; &lt; / d i v &gt; &lt; d i v s t y l e = &quot; w i d t h : 155 p x ; t e x t a l i g n : c e n t e r &quot; &gt; . request-&gt;type) . &#x27;&quot; alt=&quot;barcode&quot; /&gt;&lt;/div&gt;&lt;div style=&quot;width: 155px;text-align: center&quot;&gt;&#x27;. request->fn_sku.’

’. KaTeX parse error: Expected 'EOF', got '}' at position 121: …'; }̲else{ …cc->getBarcodePNG($request->num, r e q u e s t &gt; t y p e ) . &quot; a l t = &quot; b a r c o d e &quot; / &gt; &lt; / d i v &gt; &lt; d i v s t y l e = &quot; w i d t h : 155 p x ; t e x t a l i g n : c e n t e r &quot; &gt; . request-&gt;type) . &#x27;&quot; alt=&quot;barcode&quot; /&gt;&lt;/div&gt;&lt;div style=&quot;width: 155px;text-align: center&quot;&gt;&#x27;. request->fn_sku.’
’.$title.’…New
MADE IN CHINA
’;
}
}
}
}

调用接口:http://192.168.22.234/index.php/barcode?fn_sku=X001Z2ZLCC&num=454661&type=C128A&title=Attoomasauasas Mesh Showesasasadasdsadr...New
在这里插入图片描述

二维码生成
use Milon\Barcode\DNS1D;
use Milon\Barcode\DNS2D;
//生成二维码
public function qrCode(){
KaTeX parse error: Expected 'EOF', got '&' at position 49: …br><br><br><br>&̲nbsp;&nbsp;&nbs…cc->getBarcodeSVG(“AZ:X4CTAAHKI5A6TEYW9RCJNFOFWI”, “DATAMATRIX”);

}

猜你喜欢

转载自blog.csdn.net/weixin_39815001/article/details/84545890