/
ZPL label format output resolution(DPI Support)


Title 

DPI support in label

Author(s)

@naveenkumar

Team (POD)

Support-POD

Reviewer(s)

@shikar-sharma2 @avs

  • Requirement :

    DPI (Dots Per Inch) Support in Label:

    • By default, the output for the ZPL format is set to 203 DPI. need to make the DPI setting dynamic.

  • Approach :

changes in cloud function (pdfToZpl)+ code free label

Consignment-label changes :

In organisationconfig.json, we add the key “zplFormatDPI" corresponding to the organisationId.

in pdfToZplDataStream.jsgetZplApiResult() , we add

const dpi = orgConfig[orgId].zplFormatDPI || 203;

by default we hardcode to 203, if “zplFormatDPI” key not present w.r.t. organisationId & we pass dpi to
cloud Function request Body.


1body: { 2 pdfFile: pdfbase64, 3 organisationId: orgId, 4 dpi: dpi 5 }


Present Cloud Function :

1def lambda_handler(event, context): 2 # requestBody = json.loads(event.get('body')) 3 # pdfFile = requestBody['pdfFile'] 4 pdfFile = event['pdfFile'] 5 if not pdfFile: 6 return { 7 'statusCode': 200, 8 'body': json.dumps({"reason": "data not present"}) 9 } 10 try: 11 pdfFileStr = base64.b64decode(pdfFile) 12 pagesZpl = GRF.from_pdf(pdfFileStr, 'DEMO') 13 zplString = "" 14 for grf in pagesZpl: 15 grf.optimise_barcodes() 16 zplString += grf.to_zpl() 17 18 encodedZplString = base64.b64encode(zplFormatStr.encode()) 19 decodedZplString = encodedZplString.decode('ascii') 20 return dict( 21 statusCode=200, 22 body=json.dumps({"data": decodedZplString}), 23 isBase64Encoded=True 24 ) 25 except Exception as e: 26 print(e) 27 return { 28 'statusCode': 400, 29 'body': json.dumps({"reason": "unable to generate zpl file"}) 30 } 31 32


changes in Cloud Function :

Taking dpi = event['dpi']

at line 12 in cloud function , We add “dpi”,
GRF.from_pdf(pdfFileStr, 'DEMO', dpi )