我正在尝试使用 javascript
打印图像:
function printImage(src){
var printWindow = window.open('', 'Print Window','height=400,width=600');
printWindow.document.write('<html><head><title>Print Window</title>');
printWindow.document.write('</head><body ><img src=\'');
printWindow.document.write(src);
printWindow.document.write('\' /></body></html>');
printWindow.document.close();
printWindow.print();
}
printImage(src); //this is image src..
打印正常,问题出在这里:
我想删除那个空白区域,因为我正在将它打印在窄纸(账单/收据纸)上。由于那个空白区域,图像打印得非常小。我试过像 set style="margin-top:-25px; margin-left: -25px;"
on img
但它的打印像:
如何在 left top
上打印 image
而没有任何空白?
帮帮我.. 谢谢..
最佳答案
你可以试试css @page
@page {
size: auto;
margin: 0;
}
关于javascript - 如何在 javascript/css 中删除窗口的边距或填充?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29793102/