From 98b5d325272bd860223731bc9c97908dfb979cf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Katzer?= Date: Thu, 24 Jan 2019 12:12:50 +0100 Subject: [PATCH] Allow negative values for maxPages maxPages: -1 means to skip the last page --- src/ios/APPPrinterRenderer.m | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ios/APPPrinterRenderer.m b/src/ios/APPPrinterRenderer.m index 8edbe8b..6e0d392 100644 --- a/src/ios/APPPrinterRenderer.m +++ b/src/ios/APPPrinterRenderer.m @@ -71,7 +71,12 @@ NSInteger num = [super numberOfPages]; id maxPages = _settings[@"maxPages"]; - return maxPages ? MIN(num, [maxPages longValue]) : num; + if (maxPages < 0) + { + return MAX(1, num + [maxPages longValue]); + } + + return maxPages ? MAX(1, MIN(num, [maxPages longValue])) : num; } #pragma mark -