我正在尝试使用 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/