From 82ba5c4a59790cdb20a527d8c0f3de70fac8593d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Katzer?= Date: Tue, 12 Feb 2019 12:44:33 +0100 Subject: [PATCH] Allow `margin:false` as a shortcut for no margins --- src/android/PrintOptions.java | 3 ++- src/ios/APPPrinterLayout.m | 11 +++++++---- src/windows/PrinterProxy.js | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/android/PrintOptions.java b/src/android/PrintOptions.java index e34b26f..e752e41 100644 --- a/src/android/PrintOptions.java +++ b/src/android/PrintOptions.java @@ -89,6 +89,7 @@ class PrintOptions { @NonNull PrintAttributes toPrintAttributes() { PrintAttributes.Builder builder = new PrintAttributes.Builder(); + Object margin = spec.opt("margin"); switch (spec.optString("orientation")) { @@ -112,7 +113,7 @@ class PrintOptions { } } - if (!spec.optBoolean("border", true)) + if (margin instanceof Boolean && !((Boolean) margin)) { builder.setMinMargins(NO_MARGINS); } diff --git a/src/ios/APPPrinterLayout.m b/src/ios/APPPrinterLayout.m index 6fc2214..2c67c95 100644 --- a/src/ios/APPPrinterLayout.m +++ b/src/ios/APPPrinterLayout.m @@ -36,10 +36,13 @@ NSDictionary *margin = spec[@"margin"]; - _contentInsets = UIEdgeInsetsMake([APPPrinterUnit convert:margin[@"top"]], - [APPPrinterUnit convert:margin[@"left"]], - [APPPrinterUnit convert:margin[@"bottom"]], - [APPPrinterUnit convert:margin[@"right"]]); + if ([margin isKindOfClass:NSDictionary.class]) + { + _contentInsets = UIEdgeInsetsMake([APPPrinterUnit convert:margin[@"top"]], + [APPPrinterUnit convert:margin[@"left"]], + [APPPrinterUnit convert:margin[@"bottom"]], + [APPPrinterUnit convert:margin[@"right"]]); + } _maximumContentWidth = [APPPrinterUnit convert:spec[@"maxWidth"]]; diff --git a/src/windows/PrinterProxy.js b/src/windows/PrinterProxy.js index e0fa74c..0bf05da 100644 --- a/src/windows/PrinterProxy.js +++ b/src/windows/PrinterProxy.js @@ -138,7 +138,7 @@ exports.onPrintTaskRequested = function (event) { spec.mediaType = Printing.PrintMediaType.photographic; } - if (config.border === false) { + if (config.margin === false) { spec.bordering = Printing.PrintBordering.borderless; }