6

I have this little latex file generating a qr-code using Hendrickson's qrcode.sty found here: pgf-Tikz QR code generator.

\documentclass[english,11pt,a4paper]{article}
\usepackage{qrcode}
\begin{document}
\qrcode{
BEGIN:VCARD^^J
VERSION:4.0^^J
N:Doe;John^^J
TEL;WORK:+1 (234) 567-8910^^J
EMAIL:john@doe.com^^J
END:VCARD
}
\end{document}

It generates indeed the following qr-code but when i scan it with my phone, I get no information.

QR-code with non info.

How should I do it?

Regards, F.

Fuji San
  • 225

4 Answers4

3

Even after you remove the trailing ^^J, it won't work quite the way you wanted, as others have noted. After some experimenting, I found that removing all regular newlines and adding \? (which is qrcode's marker for "newline") does the trick:

\qrcode{BEGIN:VCARD\?VERSION:4.0\?N:Doe;John\?TEL;TYPE=work:+1(234)567-8910\?EMAIL:john@doe.com\?END:VCARD}

(with no linebreak) works exactly the way you want, at least when I check it with my phone. Here's what it looks like:

John Doe vcard, via \qrcode

creichen
  • 131
1

The 2 qrcode generated here are not the same and the first doesn't give any info. The second does for me. So you see, same vcard format.

\documentclass[english,11pt,a4paper]{article}

\usepackage{qrcode}
\usepackage[utf8]{inputenc} 
\usepackage{pst-barcode}

{\obeylines\gdef^^M{^^J}%
 \catcode`\@=0 %
 \catcode`\\=12 %
 @gdef@n{\n}}

\usepackage{auto-pst-pdf} % uncomment this if used with pdflatex

\begin{document}

\qrcode{
BEGIN:VCARD
VERSION:4.0
N:Doe;John
TEL;TYPE=work:+1(234)567-8910
EMAIL:john@doe.com
END:VCARD
}

\medskip
\begin{pspicture}(1in,1in)
\obeylines
\psbarcode{%
BEGIN:VCARD
VERSION:4.0
N:Doe;John
TEL;TYPE=work:+1(234)567-8910
EMAIL:john@doe.com
END:VCARD
}{width=1. height=1.}{qrcode}%
\end{pspicture}

\end{document}

enter image description here

Fuji San
  • 225
0

Rin with xelatex

\documentclass{article}
\usepackage{pst-barcode}
\begin{document}

\begin{pspicture}(1in,1in)
\psbarcode{%
        BEGIN:VCARD^^J
        VERSION:4.0^^J
        N:Doe;John^^J
        TEL;WORK:+1 (234) 567-8910^^J
        EMAIL:john@doe.com^^J
        END:VCARD
    }{encoding=raw}{qrcode}
\end{pspicture}
\end{document}

enter image description here

-1

This is not a latex issue, the format of your vcard is wrong.

Try the following:

\documentclass[english,11pt,a4paper]{article}
\usepackage{qrcode}
\begin{document}
\qrcode{
BEGIN:VCARD
VERSION:4.0
N:Doe;John;;;
TEL;TYPE=work:+1 (234) 567-8910
EMAIL:john@doe.com
END:VCARD
}
\end{document}