2

I'm trying to embed a QR code into a document, but also has it be a clickable link, so that it can be scanned when printed, or clicked when viewed. When I do this

\documentclass{article}

\usepackage{hyperref}
\usepackage{pst-barcode}

\begin{document}

\href{http://example.com}{%
\begin{pspicture}(1in,1in)%
  \psbarcode[]{http://example.com}{}{qrcode}%
\end{pspicture}}

\end{document}

the entire page turns into a link, not just the QR code.

1 Answer 1

2
\documentclass{article}
\usepackage{auto-pst-pdf}
\usepackage{hyperref}
\usepackage{pst-barcode}

\begin{document}

\href{http://example.com}{%
\begin{pspicture}(1in,1in)
  \psbarcode[]{http://example.com}{}{qrcode}
\end{pspicture}}

\end{document}

works fine with pdflatex --shell-escape <file>

enter image description here

If you still need xelatex to run, you can create the QR code first as image:

\documentclass{scrartcl}%% save file _not_ as QR.tex
\usepackage{fontspec}
\usepackage{fancyvrb}
\usepackage{graphicx}
\usepackage{hyperref}

\begin{document}
\begin{VerbatimOut}{QR.tex}
\documentclass[pstricks]{standalone}
\usepackage{pst-barcode}
\begin{document}
\begin{pspicture}(1.8cm,1.8cm)
  \psbarcode{http://example.com}{}{qrcode}
\end{pspicture}
\end{document}
\end{VerbatimOut}

\immediate\write18{xelatex QR}%% 

\href{http://example.com}{\includegraphics{QR}}

\end{document}
3
  • It doesn't seem to make a difference in xelatex (I'm using a lot of xetex-specific features so unfortunately I can't switch now).
    – Maskull
    Sep 21, 2015 at 15:53
  • it is a problem with the xetex driver. You can create the QR on-the-fly as an image, see my edited answer
    – user2478
    Sep 21, 2015 at 16:10
  • Oh wow, that's cool. That works for me.
    – Maskull
    Sep 21, 2015 at 18:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .