# Create labels with QR code

**URL:** https://discourse.nodered.org/t/create-labels-with-qr-code/48122
**Category:** General
**Created:** [7 July 2021 09:20 UTC](https://discourse.nodered.org/t/create-labels-with-qr-code/48122 "2021-07-07T09:20:13Z")
**Posts on this page:** 1
**Showing post:** 10

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [7 July 2021 11:10 UTC](https://discourse.nodered.org/t/create-labels-with-qr-code/48122/10 "2021-07-07T11:10:08Z")

</div>

here you go, you can use this as a basis - happy hacking...

```auto
[{"id":"fe9b4ed7647d2453","type":"Barcode Generator","z":"f9687f620c582b41","name":"","data":"partNumber","dataType":"msg","barcode":"qrcode","barcodeType":"barcode","options":"","optionsType":"ui","sendProperty":"payload","props":[{"p":"rotate","v":"N","vt":"str"},{"p":"includetext","v":"false","vt":"bool"},{"p":"backgroundcolor","v":"ffffff","vt":"str"}],"x":1130,"y":900,"wires":[["76c9df14f742d291"]]},{"id":"4482d582a64a9f20","type":"inject","z":"f9687f620c582b41","name":"start","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":930,"y":820,"wires":[["8c9a3d2abb774c9d"]]},{"id":"8c9a3d2abb774c9d","type":"template","z":"f9687f620c582b41","name":"CSV data","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"TRX1188-WHT-LXL; Logo Hat White L / XL; 2\nTRX1252; NUT SET LOCK NUTS 3mm 11 A; 2","output":"str","x":1060,"y":820,"wires":[["4c27d54dde0e8ad8"]]},{"id":"4c27d54dde0e8ad8","type":"csv","z":"f9687f620c582b41","name":"","sep":";","hdrin":"","hdrout":"none","multi":"one","ret":"\\n","temp":"partNumber,description,printCount","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":1190,"y":820,"wires":[["76ff06107b4d6e9d"]]},{"id":"76ff06107b4d6e9d","type":"delay","z":"f9687f620c582b41","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"2","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"x":1340,"y":820,"wires":[["1229bd20fced9377","415111597bd00f93"]]},{"id":"1229bd20fced9377","type":"change","z":"f9687f620c582b41","name":"","rules":[{"t":"set","p":"printCount","pt":"msg","to":"payload.printCount","tot":"msg"},{"t":"set","p":"description","pt":"msg","to":"payload.description","tot":"msg"},{"t":"set","p":"partNumber","pt":"msg","to":"payload.partNumber","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":960,"y":900,"wires":[["fe9b4ed7647d2453"]]},{"id":"43596d88a839fdd8","type":"function","z":"f9687f620c582b41","name":"Duplicate x number of times","func":"let printCount = msg.printCount || 1;\n\nfor (let index = 0; index < printCount; index++) {\n msg.printNumber = index+1;\n msg.info = `${index+1} of ${printCount}`;\n node.send(msg);\n}\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1040,"y":1040,"wires":[["7ef48abff1964233"]]},{"id":"7ef48abff1964233","type":"delay","z":"f9687f620c582b41","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"2","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"x":1280,"y":1040,"wires":[["01ea5e8f9f1a298c","0523409d8ef27edc"]]},{"id":"01ea5e8f9f1a298c","type":"debug","z":"f9687f620c582b41","name":"","active":false,"tosidebar":false,"console":false,"tostatus":true,"complete":"info","targetType":"msg","statusVal":"info","statusType":"auto","x":1480,"y":1040,"wires":[]},{"id":"415111597bd00f93","type":"debug","z":"f9687f620c582b41","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"payload","statusType":"auto","x":1530,"y":820,"wires":[]},{"id":"1d415f0a4f9650fc","type":"pdfmake","z":"f9687f620c582b41","name":"","outputType":"Buffer","inputProperty":"payload","options":"{}","outputProperty":"payload","x":1160,"y":1120,"wires":[["3cfb0dd56eb01b8f"]]},{"id":"0523409d8ef27edc","type":"function","z":"f9687f620c582b41","name":"generate pdf","func":"\nvar description = `${msg.partNumber}\\n${msg.description}`;\n\nvar dd = {\n content: [\n {\n columns: [\n {\n image: msg.image,\n width: 80\n },\n { \n width: 'auto',\n fontSize: 18,\n text: description, \n // margin: [left, top, right, bottom]\n margin: [10, 2, 10, 2]\n },\n ]\n }\n ]\n}\n\nmsg.payload = dd;\nmsg.filename = \"c:/temp/\" + msg.partNumber + \"-\" + msg.printNumber + \"-of-\" + msg.printCount + '.pdf';\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":990,"y":1120,"wires":[["1d415f0a4f9650fc"]]},{"id":"3cfb0dd56eb01b8f","type":"file","z":"f9687f620c582b41","name":"","filename":"","appendNewline":false,"createDir":false,"overwriteFile":"true","encoding":"none","x":1310,"y":1120,"wires":[[]]},{"id":"76c9df14f742d291","type":"jimp-image","z":"f9687f620c582b41","name":"to Base64","data":"payload","dataType":"msg","ret":"b64","parameter1":"FONT_SANS_32_BLACK","parameter1Type":"jimpFont","parameter2":"115","parameter2Type":"num","parameter3":"15","parameter3Type":"num","parameter4":"partNumber","parameter4Type":"msg","parameter5":"HORIZONTAL_ALIGN_LEFT","parameter5Type":"AlignX","parameter6":"VERTICAL_ALIGN_TOP","parameter6Type":"AlignY","parameter7":"","parameter7Type":"auto","parameter8":"","parameter8Type":"auto","sendProperty":"image","sendPropertyType":"msg","parameterCount":0,"jimpFunction":"none","selectedJimpFunction":{"name":"none","fn":"none","description":"Just loads the image.","parameters":[]},"x":1280,"y":900,"wires":[["43596d88a839fdd8","af4dde64ef453862"]]},{"id":"af4dde64ef453862","type":"image viewer","z":"f9687f620c582b41","name":"","width":"80","data":"image","dataType":"msg","active":true,"x":1470,"y":900,"wires":[[]]}]

```

![t2kh8nUBuO](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/a/1a4241d217d1690de6d37bab492da13918a6660c.gif)

files created...

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/9/290c82b0cd6ee0e103fcc0275209c791651496fc.png)

Example result...  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/e/deb51a61a8ec7263f36baf7e055fd6c7aeccfd2e.png)

* * *

NOTE: you will need to install `node-red-contrib-pdfmake`

---

_[View the full topic](https://discourse.nodered.org/t/create-labels-with-qr-code/48122)._
