Javascript 角度js中的静默打印
在anular js中使用了下面的打印指令来打印文档Javascript 角度js中的静默打印,javascript,java,angularjs,jakarta-ee,printing,Javascript,Java,Angularjs,Jakarta Ee,Printing,在anular js中使用了下面的打印指令来打印文档 (function (angular) { 'use strict'; function printDirective() { var printSection = document.getElementById('printSection'); // if there is no printing section, create one if (!printSection)
(function (angular) {
'use strict';
function printDirective() {
var printSection = document.getElementById('printSection');
// if there is no printing section, create one
if (!printSection) {
printSection = document.createElement('div');
printSection.id = 'printSection';
document.body.appendChild(printSection);
}
function link(scope, element, attrs) {
element.on('click', function () {
var elemToPrint = document.getElementById(attrs.printElementId);
if (elemToPrint) {
printElement(elemToPrint);
//window.print();
}
});
window.onafterprint = function () {
printSection.innerHTML = '';
}
}
function printElement(elem) {
// clones the element you want to print
var domClone = elem.cloneNode(true);
printSection.innerHTML = '';
printSection.appendChild(domClone);
window.print();
}
return {
link: link,
restrict: 'A'
};
}
angular.module('app').directive('ngPrint', [printDirective]);
}(window.angular));
这将提示模式框选择打印和其他打印配置
<button class="btn" ng-print print-element-id="printThisElement"><i class="fa fa-print"></i> Print</button>
打印
现在,我需要移除模式框并进行静默打印,在这里我们可以通过angular js代码设置哪台打印机、打印数量和其他打印配置,它应该可以在所有浏览器中工作
我们可以在客户机上添加任何机器设置,以便在客户机系统中使用默认打印机配置实现静默打印。我认为浏览器不允许这样做。如果有任何解决方法,可以实现这一点,这是一个使用angular js和Java/J2EE的web应用程序,我不这么认为。等待其他SO用户,他们可能会有一些解决方法。我不认为浏览器会允许有任何解决方法来实现这一点,这是一个使用angular js和Java/J2EE的web应用程序。我不这么认为。等待其他SO用户,他们可能有一些工作要做。