2016-03-30 15 views
1
function printData() 
{ 
    var divToPrint=document.getElementById("myprinttd"); 

    document.getElementById("myprinttd").style.fontSize = "2px"; 

    newWin= window.open(""); 
    newWin.document.write(divToPrint.outerHTML); 
    newWin.print(); 
    newWin.close(); 
} 

我正在使用上面的函數來打印屏幕。我想要減小字體大小並減少數據之間的空白,但我不能。任何人都可以幫忙。在此先感謝如何在javascript print()函數中設置fontsize

回答

0

打印輸出可能看起來與預期不同的一個原因是,除了正確設置的fontSize屬性之外,其他父元素及其CSS規則會影響元素的外觀。

outerHTML僅捕獲直接附加到所選元素的樣式,因此某些樣式信息可能會丟失。

相關問題