如何使用javascript功能打印在打印页面上添加页眉和页码 [英] How can add header and page number on printed page, using javascript fuction to print
本文介绍了如何使用javascript功能打印在打印页面上添加页眉和页码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的Web应用程序中,
将Stringbuilder数据分配给Div的innerhtml,并使用javascript函数进行打印.
现在,我需要添加页眉和页码.怎么做
下面的javascript函数.
In my web application ,
Stringbuilder data assigned to a innerhtml of a Div, and printing using javascript function.
Now I need to add a page header and page number. How can do it.
javascript functiion below.
function PrintDivision(elementId) {
var printContent = document.getElementById(elementId);
var windowUrl = 'about:blank';
var uniqueName = new Date();
var windowName = 'Print' + uniqueName.getTime();
var printWindow = window.open(windowUrl, windowName, 'left=200,top=200,width=1000,height=1000');
printWindow.document.write(printContent.innerHTML);
printWindow.document.close();
printWindow.focus();
printWindow.print();
printWindow.close();
}
推荐答案
在您的elementId的HTML中:
添加页脚,页码,不应用任何显示.在打印时,只需不显示任何内容并进行打印即可.打印后,您可以再次不应用显示.
In the HTML of your elementId:
Add Footer, page number with display none applied to it. While printing just remove display none and print. After print you can again apply display none to it.
这篇关于如何使用javascript功能打印在打印页面上添加页眉和页码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文