2017-08-27 32 views
1

这是我的HTML代码与thymeleaf一起。在这里,在div条形码正确生成,因为我需要它。但是,使用我的条码打印机打印时,我无法正确打印。有什么方法可以使用css或媒体查询或媒体打印来正确打印条形码吗?如何使用jquery打印div内生成的条形码?

<div th:id="'barcode'+${status.index}" style="margin-left:105px; width:100px;"> 
</div> 
<a class="btn btn-info" th:id="'print'+${status.index}" href="#" 
    th:onclick="'printValue('+${status.index}+');'" >Generate Barcode 
</a> 

这是我的JavaScript功能生成条形码和打印:

function printValue(x){ 
    $("#barcode"+x).barcode($("#txtbarcode"+x).val(),"code128"); 
    $("#barcode"+x).rotate(90); 
    $.print("#barcode"+x); 
} 

回答

0

你可以尝试设置barWidthbarHeight参数,如:

$("#barcode"+x).barcode(
    $("#txtbarcode"+x).val(), 
    "code128", 
    { barWidth: 1, barHeight: 50 } 
);