Skip to Content
0
Jun 14, 2021 at 07:56 PM

SAP MDK how to resize an Image

458 Views

Hi All,

We have a requirement to generate a barcode for the Work Order number which we are able to achieve using nativescript-zxing. However the image looks okay in Android but very small in IOS, how can we change the image size?
Barcode Generator

export default function ZBarcodeGenerator(context) {
const pageProxy = context.getPageProxy();
var ZXing = require('nativescript-zxing');
var ImageSource = require("tns-core-modules/image-source");
var zx = new ZXing();
const result = zx.createBarcode({
encode: context.binding.OrderId,
height: 500,
width: 1000, 
format: ZXing.CODE_128
});

var image = ImageSource.fromNativeSource(result);
image.resize(500);
var base64Str = image.toBase64String('png');
return "data:image/png;base64," + base64Str;
}
Page
{
"EmptySection": {
"FooterVisible": false
},
"ImageCells": [
{
"ImageCell": {
"Image": "/ZSAM2010/Rules/Common/ZBarcodeGenerator.js",
"ImageIsCircular": false,
"Styles": {
"Image": "barcode"
},
"Title": "{OrderId}",
"Visible": true
}
}
],
"Layout": {
"LayoutType": "HorizontalFit"
},
"Visible": true,
"_Name": "SectionImageCollection0",
"_Type": "Section.Type.ImageCollection"
}

Regards,

Ratnakar