diff --git a/CHANGELOG.md b/CHANGELOG.md index 373ab7d..a71a0f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,8 @@ - [__change__:] `isAvailable` returns false if no enabled print services can be found (Android) - [enhancement:] `isAvailable` returns additional list of available print services (Android) - [enhancement:] `print` returns bool value to indicate the result -- [enhancement:] Support `duplex` attribute (Android) +- [enhancement:] Added missing `duplex` support (Android) +- [__change__:] `duplex` requires a string (`none`, `long` or `short`) #### Version 0.7.1 (23.04.2015) diff --git a/src/ios/APPPrinter.m b/src/ios/APPPrinter.m index b3f10c1..6318ebc 100755 --- a/src/ios/APPPrinter.m +++ b/src/ios/APPPrinter.m @@ -117,6 +117,7 @@ UIPrintInfo* printInfo = [UIPrintInfo printInfo]; UIPrintInfoOrientation orientation = UIPrintInfoOrientationPortrait; UIPrintInfoOutputType outputType = UIPrintInfoOutputGeneral; + UIPrintInfoDuplex duplexMode = UIPrintInfoDuplexNone; if ([[settings objectForKey:@"landscape"] boolValue]) { orientation = UIPrintInfoOrientationLandscape; @@ -126,10 +127,17 @@ outputType = UIPrintInfoOutputGrayscale; } + if ([[settings objectForKey:@"duplex"] isEqualToString:@"long"]) { + duplexMode = UIPrintInfoDuplexLongEdge; + } else + if ([[settings objectForKey:@"duplex"] isEqualToString:@"short"]) { + duplexMode = UIPrintInfoDuplexShortEdge; + } + printInfo.outputType = outputType; printInfo.orientation = orientation; + printInfo.duplex = duplexMode; printInfo.jobName = [settings objectForKey:@"name"]; - printInfo.duplex = [[settings objectForKey:@"duplex"] boolValue]; controller.printInfo = printInfo; controller.showsPageRange = NO; diff --git a/www/printer.js b/www/printer.js index 0d802ab..b3fd318 100755 --- a/www/printer.js +++ b/www/printer.js @@ -1,5 +1,5 @@ /* - Copyright 2013-2014 appPlant UG + Copyright 2013-2016 appPlant GmbH Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file @@ -21,11 +21,6 @@ var exec = require('cordova/exec'); -/** - * The default document/job name. - */ -exports.DEFAULT_DOC_NAME = 'unknown'; - /** * List of all available options with their default value. * @@ -33,9 +28,10 @@ exports.DEFAULT_DOC_NAME = 'unknown'; */ exports.getDefaults = function () { return { - name: exports.DEFAULT_DOC_NAME, - duplex: true, + name: 'unknown', + duplex: 'none', landscape: false, + graystyle: false, bounds: [40, 30, 0, 0] }; }; @@ -87,7 +83,7 @@ exports.print = function (content, options, callback, scope) { params = this.mergeWithDefaults(params); if ([null, undefined, ''].indexOf(params.name) > -1) { - params.name = this.DEFAULT_DOC_NAME; + params.name = this.getDefaults().name; } exec(fn, null, 'Printer', 'print', [page, params]); @@ -117,6 +113,10 @@ exports.mergeWithDefaults = function (options) { ]; } + if (options.duplex && typeof options.duplex == 'boolean') { + options.duplex = options.duplex ? 'long' : 'none'; + } + for (var key in defaults) { if (!options.hasOwnProperty(key)) { options[key] = defaults[key];