Generating barcodes and QR codes with LaTeX
|
Easy to Call
The process of including references to links in a print publication can be difficult because the references must be typed in. However, if they are printed as a QR code, then it is easy to scan the code and use it to quickly call up the website.
Listing 4 shows an example for converting a URL into a QR code that in principle, functions exactly like text. The scanner app can figure out that it is dealing with a link from the prefix http://. In this example, I colored the QR code with blue using the command in the square brackets.
Listing 4
URL to QR Code
&&nonumber \psbarcode[linecolor=blue]{http://www.linuxuser.de}{}{qrcode}
Figure 2 shows the result in the second position from the left. Although black QR codes offer the greatest amount of contrast and therefore also readability, scanner apps can typically deal with colored QR codes.
The color does need to be dark enough to stand out against the background color. Light-colored QR codes on a dark background present problems. The scanner app must first invert the colors in order to read the code. Not all apps are up to the task of inverting colors.
Quick Connection
WiFi access data can be just as problematic as links when they have to be typed in by hand. However, when access data is represented as a QR code, it becomes easy to quickly create a connection. Listing 5 contains an example for the creation of a corresponding QR code.
Listing 5
Connect to WiFi
&&nonumber \psbarcode{WIFI:T:WPA;S:MyWLAN;P:MyPassword;;}{}{qrcode} \uput{0pt}[90]{90}(2.25,0){\textsf{\tiny{WLAN-Zugangsdaten}}}
Once again, you will see the well-known command for the QR code in the first line – except that here the value represents WiFi access data. The scanner app recognizes this from the WIFI: prefix and then typically generates the WiFi connection after a button push. Next comes the type of encryption, the SSID, and the password.
This example includes a command from the PSTricks package in line 2. The command inside the third set of braces is responsible for making the text WiFi access data also appear in the smallest possible san serif font size. It appears at a distance of zero points (value in the first set of curly braces) from the lower left corner (value in square brackets) at an angle of 90 degrees and rotated by 90 degrees (second set of curly braces). You will find the result in Figure 2 in the position second from the right.
« Previous 1 2 3 Next »
Buy this article as PDF
Pages: 3
(incl. VAT)