Reputation: 167
It's possible in a Google Chrome App print silent like when Chrome is running in kiosk mode?
--kiosk --kiosk-priting
Upvotes: 1
Views: 4117
Reputation: 537
I have setting:
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --kiosk-printing --profile-directory="Profile 1"
Website testing with jquery library https://printjs.crabbly.com/ Chrome Popup printer auto close and not print out..
Upvotes: 0
Reputation: 117
I found a temporary (maybe not temporary :) ) solution for this subject:
SOLUTION FOR CHROME APP
Install your App to chrome
Create shortcut from this app to desktop.
Right click > Properties > Edit Target Textbox like the below (you will add "--kiosk-printing" parameter )
Before Edit: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --profile-directory="Profile 2" --app-id=eoaefbbbpgcbhgeilphgobiicboopknp
After Edit: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --kiosk-printing --profile-directory="Profile 2" --app-id=eoaefbbbpgcbhgeilphgobiicboopknp
Try to print
If you want to remove default header and footer (page address and date) : Open normal chrome print something > on printer preview > More Settings > uncheck "Header and Footer". Chrome ll remember this settings always.
(In fact chrome must provide this property on manifest.json too, but i couldnt find yet)
Upvotes: 0
Reputation: 13681
When you print something in kiosk mode things gets printed automatically to the default printer, silently. Simply call print()
in the context of the page you want to print. If you want to print from the background/event page you will need to do something like the following:
// ...
function closePrint () {
document.body.removeChild(this.__container__);
}
function setPrint () {
this.contentWindow.__container__ = this;
this.contentWindow.onbeforeunload = closePrint;
this.contentWindow.onafterprint = closePrint;
this.contentWindow.print();
}
function printPage (sURL) {
var oHiddFrame = document.createElement("iframe");
oHiddFrame.onload = setPrint;
oHiddFrame.style.visibility = "hidden";
oHiddFrame.style.position = "fixed";
oHiddFrame.style.right = "0";
oHiddFrame.style.bottom = "0";
oHiddFrame.src = sURL;
document.body.appendChild(oHiddFrame);
}
//...
Simply call printPage
, passing a URL, to print something.
Code from MDN
Upvotes: 0