support for windows 10 UWP apps
This commit is contained in:
parent
a4f5dd098f
commit
970060a28e
@ -4,11 +4,12 @@
|
||||
- [__change__:] Plugin requires Android KitKat or newer
|
||||
- [__change__:] `isAvailable` returns false if no enabled service can be found (Android)
|
||||
- [feature:] New `pick` interface to pick a printer for future usage
|
||||
- [feature:] Initial support for Windows10 platform (Thanks to #cristi-badila)
|
||||
- [enhancement:] `isAvailable` returns count of available services (Android)
|
||||
- [enhancement:] `print` returns bool value to indicate the result
|
||||
- [enhancement:] Added missing `duplex` support (Android)
|
||||
- [__change__:] `duplex` requires a string (`none`, `long` or `short`)
|
||||
- [enhancement:] Support for `hidePageRange`, `hideNumberOfCopies` and `hidePaperFormat` (iOS specific)
|
||||
- [enhancement:] Support for `border`, `hidePageRange`, `hideNumberOfCopies` and `hidePaperFormat` (iOS specific)
|
||||
|
||||
|
||||
#### Version 0.7.1 (23.04.2015)
|
||||
|
@ -107,4 +107,12 @@
|
||||
<resource-file src="res/android/layout/select_printer_activity.xml"
|
||||
target="res/layout/select_printer_activity.xml" />
|
||||
</platform>
|
||||
|
||||
<!-- windows -->
|
||||
<platform name="windows">
|
||||
<js-module src="src/windows/PrinterProxy.js" name="PrinterProxy">
|
||||
<merges target="" />
|
||||
</js-module>
|
||||
</platform>
|
||||
|
||||
</plugin>
|
||||
|
44
src/windows/PrinterProxy.js
Normal file
44
src/windows/PrinterProxy.js
Normal file
@ -0,0 +1,44 @@
|
||||
PrinterProxy = {
|
||||
printDocumentSource: null,
|
||||
|
||||
isAvailable: function (successCallback, failCallback, args) {
|
||||
successCallback(true, 0);
|
||||
},
|
||||
|
||||
print: function (successCallback, failCallback, args) {
|
||||
var documentFragment = document.createDocumentFragment();
|
||||
var content = document.createElement("html");
|
||||
|
||||
window.printContent = args[0];
|
||||
content.innerHTML = window.printContent;
|
||||
documentFragment.appendChild(content);
|
||||
PrinterProxy.getPrintDocumentSource(documentFragment).then(function(source) {
|
||||
PrinterProxy.printDocumentSource = source;
|
||||
Windows.Graphics.Printing.PrintManager.showPrintUIAsync();
|
||||
});
|
||||
},
|
||||
|
||||
getPrintDocumentSource: function(documentFragment) {
|
||||
var promise;
|
||||
if(MSApp.getHtmlPrintDocumentSourceAsync) {
|
||||
promise = MSApp.getHtmlPrintDocumentSourceAsync(documentFragment);
|
||||
} else {
|
||||
promise = new WinJS.Promise(function(completeDispatch) {
|
||||
completeDispatch(MSApp.getHtmlPrintDocumentSource(documentFragment));
|
||||
});
|
||||
}
|
||||
|
||||
return promise;
|
||||
},
|
||||
|
||||
printTaskRequested: function (printEvent) {
|
||||
printEvent.request.createPrintTask("Print", function (args) {
|
||||
args.setSource(PrinterProxy.printDocumentSource);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var printManager = Windows.Graphics.Printing.PrintManager.getForCurrentView();
|
||||
printManager.onprinttaskrequested = PrinterProxy.printTaskRequested;
|
||||
|
||||
require("cordova/exec/proxy").add("Printer", PrinterProxy);
|
Loading…
Reference in New Issue
Block a user