Generating barcodes and QR codes with LaTeX
|
Easy to Contact
QR codes are increasing found on business cards. This makes it easy to read and save contact information in an address book. You will find an example of the relevant LaTeX code in Listing 6.
Listing 6
QR Business Card
&&nonumber 01 \obeylines 02 \psbarcode{ 03 BEGIN:VCARD^^J 04 VERSION:4.0^^J 05 N:Mustermann;Max;;^^J 06 FN:Max Mustermann^^J 07 ADR;TYPE=home:;;Hauptstr. 42;Musterstadt;;12345;Germany^^J 08 TEL;TYPE=home:+49123456789^^J 09 TEL;TYPE=cell:+49170123456789^^J 10 EMAIL:max.mustermann@example.com^^J 11 URL:http://www.example.com^^J 12 END:VCARD^^J}{}{qrcode} 13 \rput(2.15,2.2){\includegraphics{postkarte.eps}}
This time the psbarcode command contains the value for the contents of a VCard file in the first set of curly braces (lines 2 to 12). Here you must ensure that every entry in the VCard occurs on its own line. For LaTeX to make line breaks correctly, the command has to include obeylines (line 1). Additionally, you will have to specify the ends of the lines with the sequence ^^J .
QR codes have built-in error correction. Even when the scanner is unable to read a larger or smaller part of the QR code, the code can still be decrypted. This property can be used to insert a picture into the QR code. Therefore, you can add things like a photo, a logo or even an icon with a postcard as shown to the far right in the example in Figure 2.
The command from the PSTricks package in line 13 places the contents of the image file given in the set of curly braces at the coordinates specified in the parentheses. For this command to function, you will also need to add the package graphicx [7]>>8 in the preamble. Although the image now covers up a portion of the QR code, the contact information is still readable provided the photo is not too large.
Conclusion
Bar and QR codes are all around us and they provide many opportunities to quickly and conveniently read and process all different kinds of information using a smartphone or a tablet. Pst-barcode lets you create high-quality barcodes and QR codes on your own.
Infos
- Pst-barcode Package: http://ctan.org/pkg/pst-barcode
- PSTricks Package: http://www.ctan.org/pkg/pstricks-base
- Article listings: ftp://ftp.linux-magazine.com/pub/listings/ubuntu-user.com/28/LaTeX/
- XeTeX Project Page: http://tug.org/xetex/
- ImageMagick: http://imagemagick.org
- auto-pst-pdf package: http://ctan.org/pkg/auto-pst-pdf
- OpenEANDB: http://opengtindb.org
- Graphicx package: http://ctan.org/pkg/graphicx
« Previous 1 2 3 Next »
Buy this article as PDF
Pages: 3
(incl. VAT)