Part-DB-server icon indicating copy to clipboard operation
Part-DB-server copied to clipboard

Generating a QR Code with barcode_svg using twig

Open AutoGuy404 opened this issue 8 months ago • 4 comments

I am trying to generate a QR Code containing the part name for a label. I got it so far that I generated a svg string and data uri encoded it. The part that I am missing is to generate the QR Code picture to show up in the label. Can someone help me with that? Best Regards

Image

AutoGuy404 avatar Jun 09 '25 16:06 AutoGuy404

Thats the barcode encoded as data uri.

To output it as actual picture in the pdf you need to create an element, and use this data uri string as content for the src attribute.

Something like <img src="{{barcode_svg("Whatever")}}>

jbtronics avatar Jun 13 '25 09:06 jbtronics

@AutoGuy404 did you get this to work?

TheNeg0t1ator avatar Jul 07 '25 22:07 TheNeg0t1ator

I tested it and got a positive result when putting this into the content section (as HTML; click on "Source" first): <img src="{{barcode_svg(placeholder('[[NAME]]', element), 'QRCODE')|data_uri}}" height="80px">

The barcode type is now also in single quotes, so you don't have to escape it.

d-buchmann avatar Jul 22 '25 11:07 d-buchmann

I tested it and got a positive result when putting this into the content section (as HTML; click on "Source" first): <img src="{{barcode_svg(placeholder('[[NAME]]', element), 'QRCODE')|data_uri}}" height="80px">

The barcode type is now also in single quotes, so you don't have to escape it.

Could you maybe please share your whole profile / HTML code? I‘m trying to achieve the same - but unfortunately I can’t get it to work.

Edit: for everyone reading this: my user was missing the twig permission -> the profile did not have twig enabled

MayNiklas avatar Sep 08 '25 15:09 MayNiklas