Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to put a QRCode that contains contact information (VCard). However I don't know how to encode the newline character so VCard is correctly read.

Here is a sample document with QRCode without newline chars (UPDATED: I changed the example to one from de.wikipedia.org, because my iphone qrcode reader does not properly processes the example from en.wikipedia.org)):

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


\begin{document}

    \begin{pspicture}(1in,1in)
    \obeylines
    \psbarcode{%
BEGIN:VCARD
VERSION:3.0
N:Mustermann;Max
FN:Max Mustermann
ORG:Wikipedia
URL:http://de.wikipedia.org/
EMAIL;TYPE=INTERNET:max.mustermann@example.org
TEL;TYPE=voice,work,pref:+49 1234 56788
ADR;TYPE=intl,work,postal,parcel:;;Musterstraße 1;Musterstadt;;12345;Germany
END:VCARD
}{width=2.0 height=2.0}{qrcode}%
    \end{pspicture} 


\end{document}

I have found a similar question on tug.org, the conclusion was that you need to modify the generated PostScript. I wonder if there is another solution.

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

Does the following code do the right thing?

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

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

    \begin{pspicture}(1in,1in)
    \obeylines
    \psbarcode{%
BEGIN:VCARD
VERSION:3.0
N:Gump;Forrest
FN:Forrest Gump
ORG:Bubba Gump Shrimp Co.
TITLE:Shrimp Man
TEL;TYPE=WORK,VOICE:(111) 555-1212
TEL;TYPE=HOME,VOICE:(404) 555-1212
ADR;TYPE=WORK:;;100 Waters Edge;Baytown;LA;30314;United States of America
LABEL;TYPE=WORK:100 Waters Edge\n Baytown, LA 30314\n United States of America
ADR;TYPE=HOME:;;42 Plantation St.;Baytown;LA;30314;United States of America
LABEL;TYPE=HOME:42 Plantation St.\n Baytown, LA 30314\n United States of America
EMAIL;TYPE=PREF,INTERNET:forrestgump@example.com
REV:20080424T195243Z
END:VCARD
}{width=2.0 height=2.0}{qrcode}%
    \end{pspicture} 


\end{document}
share|improve this answer
    
I have an additional question. Why the command does not work when I put the pspicture in tabular. –  Skarab Jun 12 '11 at 18:37
    
@Skarab: That would be because all the tokens going into one tabular entry get scanned before they are executed, and so the category changes happen too late to do any good. You can do \setbox0\hbox{…} where stands for the entire pspicture environment, and then use \box0 in the tabular. (Note that the standard LaTeX commands \savebox and \sbox also scan their argument before executing, which is why I resort to TeX primitives here.) –  Harald Hanche-Olsen Jun 12 '11 at 19:10
2  
Another solution, which should work without the trick of the previous comment, is to drop the \obeylines and the definition of ^^M and instead manually insert ^^J at the end of each line of the vcard. –  Harald Hanche-Olsen Jun 12 '11 at 19:18
    
Works. Thank you for your help. –  Skarab Jun 12 '11 at 21:32
    
I've implemented, based on the above mentioned example, my own vcard. Can't read it properly for example using MeeScan (ver. 0.0.12). Is it the reader's fault? –  Nikos Alexandris Sep 6 '12 at 13:35
show 5 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.