Reputation: 203
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
Upvotes: 5
Views: 13280
Reputation: 203
I have found the solution to the problem
In Chrome:
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"
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:
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();
Upvotes: 6