[英]window.print() set window height width in mm when user select page size at run time
I am developing a portal in which user select page size (in mm)and when print preview open then it will be in page size which user have selected. 我正在开发一个门户,用户可以在其中选择页面大小(以毫米为单位),当打印预览打开时,它将是用户选择的页面大小。
is this possible to set page size in mm choosen by user at run time through window.open(). 是否可以通过window.open()在运行时由用户选择以mm为单位设置页面大小。
You can set size in @page
media before calling window.print
您可以在调用
window.print
之前在@page
媒体中设置大小
var css = '@page { size: 50mm 50mm; }',
head = document.head || document.getElementsByTagName('head')[0],
style = document.createElement('style');
style.type = 'text/css';
style.media = 'print';
if (style.styleSheet){
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
head.appendChild(style);
window.print();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.