QR Codes in DITA Ouput

Inspired by a thread started by Sean Healy, and building on the instructions posted by Kevin Brown, I added the ability to generate and insert QR Codes into PDF output to the mypdf plugin.

I ignore QR Codes in marketing, but I think they could be a great way to link to resources, such as videos, from printed technical documents. Readers can simply zap the codes with their phones to pull up the content.

As Kevin points out, leveraging the Google Chart API to generate QR Codes is pretty simple. You can try it in your browser by simply pasting the following URL:¬†https://chart.googleapis.com/chart?cht=qr&chs=200×200&chl=http://ditanauts.org

For the mypdf plugin, an author simply has to insert an xref and set the @outputclass to qrcode. For example:

<xref href="http://ditanauts.org" outputclass="qrcode"/>

Then the plugin uses the following template to generate and insert the image:

<!-- Insert QR code -->
<xsl:template match="*[contains(@class,' topic/xref ')]
                      [contains(@outputclass, 'qrcode')]">
<fo:external-graphic>
<xsl:attribute name="src"><xsl:value-of select="concat('https://chart.
googleapis.com/chart?cht=qr&amp;chs=100x100&amp;chl=', .)"/>
</xsl:attribute>
</fo:external-graphic>
</xsl:template>

The image is inserted at the location of the xref, so you may want to tweak the stylesheet to place the image how and where you want. By the way, from my simple tests, I’ve found that 100×100 was as small as I could make the image, and still pick it up reliably from the QR code reader on my phone.

One thought on “QR Codes in DITA Ouput

  1. You can do more with QR codes at barcodeconnections. comTrack:1. How many poelpe scan your QR code. (Total number and unique scans)2. Where poelpe scan your barcode. (The geographic location)3. When poelpe scan your barcode. (Hour by hour, in realtime)4. How long individuals spend on your website after scanning your QR code.5. Total number of website pages individuals view after scanning your QR code.6. The bounce rate of poelpe who visit your website after scanning your QR code.

Leave a Reply

Your email address will not be published. Required fields are marked *


*