diff --git a/README.md b/README.md index 9f7abac..afc08b4 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,10 @@ More informations can be found [here](https://build.phonegap.com/plugins/360). ## Release Notes +#### Version 0.6.0 (not yet released) +- [feature]: Added Windows8 support
+ *Thanks to* ***pirvudoru*** + #### Version 0.5.2 (22.03.2014) - [bugfix:] `isServiceAvailable` on Android did not return a list of available printing apps. diff --git a/plugin.xml b/plugin.xml index 2704520..e467c41 100644 --- a/plugin.xml +++ b/plugin.xml @@ -9,7 +9,7 @@ A bunch of printig plugins for Cordova 3.x.x https://github.com/katzer/cordova-plugin-printer.git - print, printer, ios, android + print, printer, ios, android, windows 8 Apache 2.0 Sebastián Katzer @@ -45,4 +45,11 @@ + + + + + + + diff --git a/src/windows8/PrinterProxy.js b/src/windows8/PrinterProxy.js new file mode 100644 index 0000000..99f6146 --- /dev/null +++ b/src/windows8/PrinterProxy.js @@ -0,0 +1,50 @@ +/* + Copyright 2013-2014 appPlant UG + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ + +PrinterProxy = { + isServiceAvailable: function (successCallback, failCallback, args) { + args[0](true); + }, + + print: function (successCallback, failCallback, args) { + window.printContent = args[0]; + + Windows.Graphics.Printing.PrintManager.showPrintUIAsync(); + }, + + printTaskRequested: function (printEvent) { + printEvent.request.createPrintTask("Print", function (args) { + var documentFragment = document.createDocumentFragment(); + var content = document.createElement("html"); + + content.innerHTML = window.printContent; + documentFragment.appendChild(content); + + args.setSource(MSApp.getHtmlPrintDocumentSource(documentFragment)); + }); + } +}; + +var printManager = Windows.Graphics.Printing.PrintManager.getForCurrentView(); + +printManager.onprinttaskrequested = PrinterProxy.printTaskRequested; + +require("cordova/windows8/commandProxy").add("Printer", PrinterProxy); \ No newline at end of file