答案 0 :(得分:0)
您可以在致电@page
之前在window.print
媒体中设置尺寸
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();