【问题标题】:Print barcodes in multiple columns打印多列条码
【发布时间】:2012-07-04 16:46:02
【问题描述】:

我有一个打印出书籍条形码和 isbn 的文档,我的问题是它只在页面上打印一列。我想每页打印 2 或 3 列(如果页面将支持那么多列)。我正在使用 javascript 生成带有书名的条形码。这是代码:

    for (x=0;x<data.isbn.length;x++)
    {
                if (x == 5){
                '<div class="page-break"></div>';
                } else 
                first += '$("#'+indexGlobal+'").barcode("'+isbn[x]+'", "codabar",{barHeight:40, fontSize:30, output:"bmp"});';
        second += '<div class="wrapper"><div id="'+indexGlobal+'"></div><div class="fullSKU">&nbsp &nbsp &nbsp '+isbn[x]+
                '</div><br/><div class="title">'+title[x]+'</div></div>&nbsp &nbsp';
        indexGlobal++;

                }
                }
            });//end of ajax call

        var barcode =  window.open('','BarcodeWindow','width=400');
        var html = '<html><head><title>Barcode</title><style type="text/css">'+
        '.page-break{display:block; page-break-before:always; }'+
        'body{width: 2in;}'+
        '.wrapper{height: 1in;margin-left:10px;margin-top:5px;margin-right:5px;}'+
        '.fullSKU{float: left;}'+
        '.shortSKU{float: right;font-size:25px;font-weight:bold;}'+
        '.title{float: left;}'+
        '</style><script type="text/javascript"src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.js"></script><script type="text/javascript" src="../barcode/jquery-barcode.js"></script><script>$(document).ready(function() {'+first+'window.print();window.close();});</script></head><body>'+second+'</body></html>';
        barcode.document.open();
        barcode.document.write(html);
        barcode.document.close();

有什么建议可以将此打印在多个列中?

【问题讨论】:

  • 生成的html是什么样子的?
  • 它打印带有书名的条形码,但仅在页面下方的一栏中。为了节省纸张,我希望能够在多列中打印。
  • 这不是我问的...html源代码是什么样的?描述它呈现的内容是没有意义的。

标签: javascript printing barcode


【解决方案1】:

我的一个朋友给我指出了正确的方向。我改变了身体的宽度

'body{width: 2in;}'+

设为页面大小(10英寸,因为它会打印横向),然后使用3列的css3属性:

'body{width: 10in;-moz-column-count:3; -webkit-column-count:3;column-count:3;}'

希望这对其他人有帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-18
    相关资源
    最近更新 更多