admin管理员组文章数量:1296505
I am doing a function to auto print the pdf file, the file is returned from the server. It is currently showing a print window, but I want the file to be printed on the printer at all times without have to press the print button.
current:
I read a lot of articles on stackoverflow, and other pages but it's failed.
Please help me! Thanks alot
I am doing a function to auto print the pdf file, the file is returned from the server. It is currently showing a print window, but I want the file to be printed on the printer at all times without have to press the print button.
current:
I read a lot of articles on stackoverflow, and other pages but it's failed.
Please help me! Thanks alot
Share Improve this question edited Jan 30, 2019 at 15:57 Richard Parnaby-King 14.9k11 gold badges73 silver badges130 bronze badges asked Oct 12, 2018 at 4:53 Hoang VinhHoang Vinh 2031 gold badge3 silver badges12 bronze badges1 Answer
Reset to default 6I have found the solution to the problem
In Chrome:
- step 1:
config run chrome silent printing on mode --kiosk-printing edit target on chrome shortcut properties Ex:"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --kiosk-printing "http://localhost:8080/this"
- step 2:
code
var iframe = document.createElement('iframe');
document.body.appendChild(iframe);
iframe.style.display = 'none';
iframe.onload = function() {
setTimeout(function() {
iframe.focus();
iframe.contentWindow.print();
}, 0);
};
iframe.src = _blobUrl;
In Firefox:
- step1: config printing silent
goto about:config create new Boolean preference name="print.always_print_silent" Value=true
step 2: code
var myWindow = window.open(_blobUrl, '_blank', 'width=800,height=600'); myWindow.focus(); myWindow.print(); myWindow.close();
本文标签: Automatic print pdf file on chrome or firefox (both lastest version) using javascriptStack Overflow
版权声明:本文标题:Automatic print pdf file on chrome or firefox (both lastest version) using javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741630834a2389352.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论