2012-07-04 28 views
0

我有一个打印条形码和isbn's书籍的文档,我的问题是它只打印页面上的一列。我想每页打印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(); 

任何建议有此打印在多个列?

+0

生成的html看起来像什么? –

+0

它打印带有本书标题的条形码,但只是在页面的一列中。为了节省纸张,我希望能够在多列中打印。 – Jim

+0

这不是我问的问题...... HTML源代码是什么样的?描述它呈现的是毫无意义的。 –

回答

0

我的一位朋友指出我正确的方向。我改变了车身的宽度

​​

是页面的尺寸(10英寸,因为它会打印横向),然后用3列的CSS3属性:

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

希望这会帮助别人。