TransWikia.com

Hot to draw a specific border around a QR-code?

TeX - LaTeX Asked on January 2, 2021

As the treasurer of an association it’s my duty to send out yearly invoices for membership dues. I use scrlttr2 on LuaLaTeX for that, and it’s working fine. To allow for easier payment, I am using a QR-Code containing the relevant payment info. That, too, works largely as expected:

documentclass{scrlttr2}

usepackage[absolute]{textpos}
usepackage[forget]{qrcode}

% usepackage[ngerman]{babel} % Not used due to conflict with qrcode

setkomavar{signature}{Nomen Nescio, Honcho in Chief} 

begin{document}
begin{letter}{To: All members}

opening{Dear all,}

Please pay up!

closing{Kthanksbye,}

begin{textblock*}{10cm}(13.5cm,22cm)%
  begin{minipage}[c]{7cm} % use ? for newline, all spaces must be prefixed with 
qrcode[height=4cm,level="M"]{BCD?001?1?SCT?ABCDATWW?Applepie Appreciation Society?AT611904300234573201?EUR90??MyUniqueReference??}
    end{minipage}
  end{textblock*}

end{letter}
end{document}

enter image description here

Apparently there is some software or app, however, that doesn’t recognize these codes unless they have a specific border drawn around them like this:

enter image description here

Is there an easy way to draw that border with LaTeX (TikZ?), or do I have to use a transparent image of the border and just position it on top of the created QR-Code? (Using AddToShipoutPicture or something similar is my plan B at this point.)

2 Answers

Thanks to your comments and contributions I was able to get it to work:

documentclass{scrlttr2}

usepackage[absolute]{textpos}
usepackage[forget]{qrcode}
usepackage{tcolorbox}
usepackage[shorthands=off,ngerman]{babel}

setkomavar{signature}{Nomen Nescio, Honcho in Chief} 

begin{document}
begin{letter}{To: All members}

opening{Dear all,}

Please pay up!

closing{Kthanksbye,}

begin{textblock*}{10cm}(13.5cm,22cm)%
  begin{minipage}[c]{6,75cm} % use ? for newline, all spaces must be prefixed with 

begin{tcolorbox}[colback=white,grow to right by=-17mm]
qrcode[height=4cm,level="M"]{BCD?001?1?SCT?ABCDATWW?Applepie Appreciation Society?AT611904300234573201?EUR90??MyUniqueReference??}
end{tcolorbox}

    end{minipage}
  end{textblock*}

begin{textblock*}{2cm}(18.25cm,23cm)%
rotatebox{90}{colorbox{white}{Zahlen mit Code}}
end{textblock*}

end{letter}
end{document}

enter image description here

Correct answer by Ingmar on January 2, 2021

Without the text I would suggest:

documentclass{scrlttr2}

usepackage[absolute]{textpos}
usepackage[forget]{qrcode}
usepackage{tcolorbox}
usepackage{lipsum}

definecolor{mycolor}{rgb}{0.122, 0.435, 0.698}


% usepackage[ngerman]{babel} % Not used due to conflict with qrcode

setkomavar{signature}{Nomen Nescio, Honcho in Chief} 

begin{document}
begin{letter}{To: All members}

opening{Dear all,}

Please pay up!

closing{Kthanksbye,}

begin{textblock*}{10cm}(13.5cm,22cm)%
  begin{minipage}[c]{7cm} % use ? for newline, all spaces must be prefixed with 

begin{tcolorbox}[colback=white,grow to right by=-17mm]
qrcode[height=4cm,level="M"]{BCD?001?1?SCT?ABCDATWW?Applepie Appreciation Society?AT611904300234573201?EUR90??MyUniqueReference??}
end{tcolorbox}
    end{minipage}
  end{textblock*}

end{letter}
end{document}

Answered by Uwe Ziegenhagen on January 2, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP