Create labels with QR code

Hello! Is it possible to create labels?

We would be happy to return labels to files are all in a CSV file.

Here is what the file looks like.

TRX1188-WHT-LXL; Logo Hat White L / XL; 2
TRX1252; NUT SET LOCK NUTS 3mm 11 A; 2

What also comes is that the first column from the QR code should be displayed and the last line is how often the label should be created.

Here's what the labels should look like
Bildschirmfoto 2021-07-07 um 11.19.23

I hope then there who can help, I can do that.

Something like...

[{"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":"true","vt":"bool"},{"p":"alttext","v":"description","vt":"msg"},{"p":"textxalign","v":"left","vt":"str"},{"p":"textxoffset","v":"22","vt":"num"},{"p":"textyoffset","v":"-12","vt":"num"},{"p":"textsize","v":"6","vt":"num"},{"p":"backgroundcolor","v":"ffffff","vt":"str"},{"p":"padding","v":"8","vt":"str"}],"x":1130,"y":900,"wires":[["76c9df14f742d291"]]},{"id":"4482d582a64a9f20","type":"inject","z":"f9687f620c582b41","name":"TRX1252; NUT SET LOCK NUTS 3mm 11 A; 2","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"TRX1252; NUT SET LOCK NUTS 3mm 11 A; 2","payloadType":"str","x":1100,"y":840,"wires":[["e24cdbf275a5523e"]]},{"id":"e24cdbf275a5523e","type":"function","z":"f9687f620c582b41","name":"","func":"//TRX1252; NUT SET LOCK NUTS 3mm 11 A; 2\n\nlet parts = msg.payload.split(\";\");\nmsg.partNumber = parts[0];\nmsg.description = parts[1];\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":980,"y":900,"wires":[["fe9b4ed7647d2453"]]},{"id":"76c9df14f742d291","type":"jimp-image","z":"f9687f620c582b41","name":"","data":"payload","dataType":"msg","ret":"img","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":"payload","sendPropertyType":"msg","parameterCount":8,"jimpFunction":"print2","selectedJimpFunction":{"name":"print aligned","fn":"print","description":"Print text to the image","parameters":[{"name":"font|str","type":"jimpFont","required":true,"hint":"font to print. NOTE: This can be one of the presets or the path to a fnt file"},{"name":"x","type":"num","required":true,"hint":"x coordinate to print text"},{"name":"y","type":"num","required":true,"hint":"y coordinate to print text"},{"name":"text","group":"options","type":"str","required":true,"hint":"text to print"},{"name":"alignmentX","group":"options","type":"AlignX","required":false,"hint":"X Alignment"},{"name":"alignmentY","group":"options","type":"AlignY","required":false,"hint":"Y Alignment"},{"name":"maxWidth","type":"auto|num","required":false,"hint":"wrap text at maxWidth"},{"name":"maxHeight","type":"auto|num","required":false,"hint":"max height"}]},"x":1290,"y":900,"wires":[["3d7e2f66feea9007"]]},{"id":"3d7e2f66feea9007","type":"image viewer","z":"f9687f620c582b41","name":"","width":"360","data":"payload","dataType":"msg","active":true,"x":1450,"y":900,"wires":[[]]}]

Requires node-red-contrib-image-tools (node) - Node-RED

Hello!

Thanks for the quick response.

Can I then save it as a PDF? and how do i do it because of the crowd? Since the last column shows how often you need the label

Maybe, with the aid of another node.

In its current form, it can be written as image to file (use another image-tools image node set the function to write

Do you mean you want 2 of the same if the last number is 2? What would be the point? They would be identical files.

Hello!

Yes, there are exactly two of those in the example. But this can only be once or four times. The number is in the last column.

Hi, sorry, that makes no sense to me. Can you perhaps explain your end goal with more details.

for example, are you wanting to generate 2 images because you want to email them to 2 separate people? Or are you intending on printing 2 labels?

My point is, there is little point creating more than 1 image if they are identical.

the number in the last column is the number of times the label should be printed.

As in the example, there are two pieces.

This would then have to be made into a PDF and then I can print it.

That makes more sense.

However, why must you create a PDF?
And why must it be saved to file twice - just print it twice!


A better solution would be to print directly from the flow (no files, just the image in memory).

e.g...
Once the barcode is generated (an image in memory), you can use the last field of the CSV data to print the generated image 1, 2, 5 or 50 times (but the barcode only needs to be generated once).

For example...

[{"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":"true","vt":"bool"},{"p":"alttext","v":"description","vt":"msg"},{"p":"textxalign","v":"left","vt":"str"},{"p":"textxoffset","v":"22","vt":"num"},{"p":"textyoffset","v":"-12","vt":"num"},{"p":"textsize","v":"6","vt":"num"},{"p":"backgroundcolor","v":"ffffff","vt":"str"},{"p":"padding","v":"8","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":"76c9df14f742d291","type":"jimp-image","z":"f9687f620c582b41","name":"","data":"payload","dataType":"msg","ret":"buf","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":"payload","sendPropertyType":"msg","parameterCount":8,"jimpFunction":"print2","selectedJimpFunction":{"name":"print aligned","fn":"print","description":"Print text to the image","parameters":[{"name":"font|str","type":"jimpFont","required":true,"hint":"font to print. NOTE: This can be one of the presets or the path to a fnt file"},{"name":"x","type":"num","required":true,"hint":"x coordinate to print text"},{"name":"y","type":"num","required":true,"hint":"y coordinate to print text"},{"name":"text","group":"options","type":"str","required":true,"hint":"text to print"},{"name":"alignmentX","group":"options","type":"AlignX","required":false,"hint":"X Alignment"},{"name":"alignmentY","group":"options","type":"AlignY","required":false,"hint":"Y Alignment"},{"name":"maxWidth","type":"auto|num","required":false,"hint":"wrap text at maxWidth"},{"name":"maxHeight","type":"auto|num","required":false,"hint":"max height"}]},"x":1290,"y":900,"wires":[["43596d88a839fdd8"]]},{"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":"print 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 = `Printing ${index+1} of ${printCount}`;\n    node.send(msg);\n}\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1020,"y":980,"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":1290,"y":980,"wires":[["3d8facec7b727cab","01ea5e8f9f1a298c"]]},{"id":"3d8facec7b727cab","type":"image viewer","z":"f9687f620c582b41","name":"image to send directly to printer","width":"360","data":"payload","dataType":"msg","active":true,"x":1610,"y":1010,"wires":[[]]},{"id":"01ea5e8f9f1a298c","type":"debug","z":"f9687f620c582b41","name":"","active":false,"tosidebar":false,"console":false,"tostatus":true,"complete":"info","targetType":"msg","statusVal":"info","statusType":"auto","x":1540,"y":952,"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":[]}]

QEV4obpYIx

That looks good. Thanks for that.

Since I do this entirely on the MAC, I prefer a PDF file to be refunded. It could be that there is a problem with the paper format. Therefore it is best to save everything in a PDF file.

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

[{"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

files created...

image

Example result...
image


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

That looks really good. Thanks for that.

can you also adjust the size of the labels? and that the PDFs also have this size?
And can we add a fixed text to the text?
Bildschirmfoto 2021-07-07 um 13.19.42

The labels are 93x33mm.

Yes, look inside the function code before PDFMake

Yes, look inside the function code before PDFMake

pdfmake documentation will also help: pdfmake

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.