Alternative to Jzebra/Qz Java Raw Print Plugin After Npapi Being Dropped on Chrome Browser

Chrome extensions for silent print?

Finally I reached an acceptable solution for this problem, as I couldn't find it out there, but read to many post with the same issue I will leave my solution here.

So first you need to add your printer to the Google Cloud Print and then you will need to add a proyect to the Google Developers Console

Then add this script and any time you need to print something execute the print() function. This method will print the document indicated in the content

The application will ask for your permission once to manage your printers.

function auth() {  gapi.auth.authorize({    'client_id': 'YOUR_GOOGLE_API_CLIENT_ID',    'scope': 'https://www.googleapis.com/auth/cloudprint',    'immediate': true  });
}
function print() { var xhr = new XMLHttpRequest(); var q = new FormData() q.append('xsrf', gapi.auth.getToken().access_token); q.append('printerid', 'YOUR_GOOGLE_CLOUD_PRINTER_ID'); q.append('jobid', ''); q.append('title', 'silentPrintTest'); q.append('contentType', 'url'); q.append('content',"http://www.pdf995.com/samples/pdf.pdf"); q.append('ticket', '{ "version": "1.0", "print": {}}');

xhr.open('POST', 'https://www.google.com/cloudprint/submit'); xhr.setRequestHeader('Authorization', 'Bearer ' + gapi.auth.getToken().access_token); xhr.onload = function () { try { var r = JSON.parse(xhr.responseText); console.log(r.message) } catch (e) { console.log(xhr.responseText) } }
xhr.send(q)
}
window.addEventListener('load', auth);
<script src="https://apis.google.com/js/client.js"></script>

Print directly from browser without print popup window

I couldn't find solution for other
browsers. When I posted this question, IE was on the
higher priority and gladly I found
one for it. If you have a solution
for other browsers (firefox, safari, opera) please do share here.
Thanks.

VBSCRIPT is much more convenient than creating an ActiveX on VB6 or C#/VB.NET:

<script language='VBScript'>
Sub Print()
OLECMDID_PRINT = 6
OLECMDEXECOPT_DONTPROMPTUSER = 2
OLECMDEXECOPT_PROMPTUSER = 1
call WB.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER,1)
End Sub
document.write "<object ID='WB' WIDTH=0 HEIGHT=0 CLASSID='CLSID:8856F961-340A-11D0-A96B-00C04FD705A2'></object>"
</script>

Now, calling:

<a href="javascript:window.print();">Print</a>

will send print without popup print window.

Print using javascript for more than 1 printers

You won't be able to control this with PHP or Javascript.

Your best option would be to write a Firefox plugin to do it for you.



Related Topics



Leave a reply



Submit