[英]Printing continuous in webpage
I'm now working on a project that requires to print some labels. 我现在正在一个需要打印一些标签的项目中。
I can print ONE label (which are html elements) with js "print" function, in this case user need to configure the printer once. 我可以使用js“打印”功能打印一个标签(即html元素),在这种情况下,用户需要配置打印机一次。 But could I print MANY different labels but configure once?
但是我可以打印很多不同的标签但只能配置一次吗?
the js printing code is: js的打印代码是:
function printElement(elem){
var win = window.open();
self.focus();
win.document.open();
win.document.write('<html><head> </head><body>');
win.document.write(elem);
win.document.write('</body></html>');
win.document.close();
win.print();
win.close();
}
Note: the paper to print have gaps, like sticky notes, so that user can tear them one by one easily. 注意:要打印的纸张有缝隙,例如粘滞便笺,因此用户可以轻松地一张一张地撕开它们。 So I cannot write all the elements on one html and print it.
因此,我无法将所有元素写在一个html上并进行打印。
Get the number of labels to print, then: 获取要打印的标签数,然后:
for( var i=0; i<labelCount; i++) {
win.document.write(elem);
}
In place of your current writing elem
. 代替当前的写作
elem
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.