Allow margin:false as a shortcut for no margins

This commit is contained in:
Sebastián Katzer 2019-02-12 12:44:33 +01:00
parent 6b4972918e
commit 82ba5c4a59
3 changed files with 10 additions and 6 deletions

View File

@ -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);
}

View File

@ -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"]];

View File

@ -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;
}