-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auto select printer and paper #57
Comments
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, i have a problem with auto select.
I use this sample code, and Please help me. How to select my printer (not first on list) after loda sprinter list? And next i need select Paper Size.
`<script src="jsprint/JSPrintManager.js"></script>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>Print Now...
<script> //Check JSPM WebSocket status function jspmWSStatus() { if (JSPM.JSPrintManager.websocket_status == JSPM.WSStatus.Open) return true; else if (JSPM.JSPrintManager.websocket_status == JSPM.WSStatus.Closed) { alert('JSPrintManager (JSPM) is not installed or not running! Download JSPM Client App from https://neodynamic.com/downloads/jspm'); return false; } else if (JSPM.JSPrintManager.websocket_status == JSPM.WSStatus.Blocked) { alert('JSPM has blocked this website!'); return false; } } var clientPrinters = null; var _this = this; //WebSocket settings JSPM.JSPrintManager.auto_reconnect = true; JSPM.JSPrintManager.start(); JSPM.JSPrintManager.WS.onStatusChanged = function () { if (jspmWSStatus()) { //get client installed printers JSPM.JSPrintManager.getPrintersInfo().then(function (printersList) { clientPrinters = printersList; var options = ''; for (var i = 0; i < clientPrinters.length; i++) { options += '' + clientPrinters[i].name + ''; } $('#lstPrinters').html(options); _this.showSelectedPrinterInfo(); }); } }; function showSelectedPrinterInfo() { // get selected printer index var idx = $("#lstPrinters")[0].selectedIndex; // get supported papers options = ''; for (var i = 0; i < clientPrinters[idx].papers.length; i++) { options += '' + clientPrinters[idx].papers[i] + ''; } $('#lstPrinterPapers').html(options); } //Do printing... function print() { if (jspmWSStatus()) { //Create a ClientPrintJob var cpj = new JSPM.ClientPrintJob(); //Set Printer info var myPrinter = new JSPM.InstalledPrinter($('#lstPrinters').val()); myPrinter.paperName = $('#lstPrinterPapers').val(); cpj.clientPrinter = myPrinter; //Set PDF file var my_file = new JSPM.PrintFilePDF($('#txtPdfFile').val(), JSPM.FileSourceType.URL, 'MyFile.pdf', 1); cpj.files.push(my_file); //Send print job to printer! cpj.sendToClient(); } } </script>`
The text was updated successfully, but these errors were encountered: