简体   繁体   English

如何在具有大小限制的laravel中生成条形码

[英]how to generate barcode in laravel with size limit

I want to generate a barcode in my project.我想在我的项目中生成一个条形码。 I have installed the milon/barcode package but the barcode which is generated by this library seems long in term of length.我已经安装了 milon/barcode 包,但是这个库生成的条形码的长度似乎很长。 I Would like to generate a barcode with a smaller length, even though the barcode string or number is too large.我想生成长度较小的条形码,即使条形码字符串或数字太大。

Is there a better way to achieve this?有没有更好的方法来实现这一目标?

Yeah!是啊! You can Set a limit which you want .您可以设置您想要的限制。
In first Step pick the specific attribute name from DB table在第一步中从数据库表中选择特定的属性名称
2- implement For each loop in that file where where you want to print barcod 2- 为该文件中的每个循环实现您要在其中打印条码的位置
3- set limit size parameter which is give below like 1,13 respectively 3- 设置限制大小参数,分别在下面给出,如 1,13
6- make class code in style tag and set height inside 6-在样式标签中制作类代码并在里面设置高度
7- go to vendor -> milion->barcode->src->Milion->DNS1d -> line no 142 7- 去vendor -> milion->barcode->src->Milion->DNS1d -> line no 142
8- Add class="code " in html tag its works properly 8- 在 html 标签中添加 class="code" 其工作正常

@section('content')
@foreach($producto as $product)
<dir>
    {!!  DNS1D::getBarcodeHTML($product->name, "C128" ,1,13)!!}


</dir>
<div style="padding-top: 30px; padding-left: 45px;  width: 500px;">
        {{$product->name}}   Rs{{$product->price}} <br>
        www.assorttech.com


</div>
@endforeach

<style> 
    .code{
        height: 60px !important;
    }

</style>
    @endsection 

Step two in DNS1D file only add class code in following code DNS1D文件中的第二步只在以下代码中添加类代码

$html .= '<div class="code" style="background-color:' . $color . ';width:' . $bw . 'px;height:' . $bh . 'px;position:absolute;left:' . $x . 'px;top:' . $y . 'px;">&nbsp;</div>' . "\n";
        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM