javascript - 打开仅显示传递的打印机名称或 IP 的打印对话框?

标签 javascript jquery printing

我正在尝试使用 jQuery.print.js 插件打印从 ajax 调用返回的 HTML 页面,一切正常,希望我需要传递打印机名称或打印机 IP 才能仅显示传递的打印机以供选择打印发生吗?

下面我会提到使用代码...

这是我的 anchor 标记,具有点击功能

    <a href="" data-order_no = "<?php echo $rest_order->id;?>" class="table-icon-saveprint icon" style="color: green;">print</a>

这是我触发预览并打开打印对话框的函数

$(document).on( 'click', '[data-order_no] ', function(e){
       e.preventDefault();
         var order_id = jQuery(this).attr('data-order_no');
         //Print ele4 with custom options
         $.ajax({
              type: 'POST',
              url: '<?php echo base_url();?>Orders/print_order',
              data: {order_id: order_id}, //How can I preview this?
              dataType: 'html',
              success: function(result){
                  $("#test_prints").print({
                         //Use Global styles
                         globalStyles : false,
                         //Add link with attrbute media=print
                         mediaPrint : false,
                         //Custom stylesheet
                         stylesheet : "http://fonts.googleapis.com/css?family=Inconsolata",
                         //Print in a hidden iframe
                         iframe : false,
                         //Don't print this
                          noPrintSelector : "#test_prints",
                         //Add this at top
                         //Add this on bottom
                         append : result, // result are html page i want to print
                         //Log to console when printing is done via a deffered callback
                         deferred: $.Deferred().done(function() { console.log('Printing done', arguments); })
                     });
              }
            });

         });

现在,当我使用 php 作为后端语言时,使用这种方式或其他方式触发打印对话框时,如何显示特定打印机?

请提供任何帮助,并提前致谢。

最好,

最佳答案

how I can display specific printers when print dialog are triggered?

浏览器中的 JavaScript 没有权限或任何类型的 API 来访问打印对话框中通常显示的任何信息。

不幸的是,此功能目前无法实现。

关于javascript - 打开仅显示传递的打印机名称或 IP 的打印对话框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45287525/

相关文章:

javascript - JSON.stringify 不带引号的属性?

javascript - 如果搜索字符串不匹配任何节点,jstree 将显示所有节点

ios - 为 ePOS-print iOS sdk 模拟打印

types - Ocaml - 多态打印和类型丢失

javascript - 开发一个简单的Firefox插件容易吗(JS注入(inject))

javascript - 如何在映射函数中累积值并将其存储在 useState 中

javascript - 访问 dropzoneJS 文件的临时源

html - 仅在打印期间必要时强制分页

javascript - jQuery 修复 "Uncaught TypeError: $ is not a function"错误

jquery - jquery 选中/取消选中复选框列表