24

Is there any package that generates 2d barcodes (QR code). I want to add a barcode on the front page of a manual I have written containing the URL where to download that manual. It would be nice if I could continue using pdflatex. Instead of converting each time.

EDIT: [Reaction to Jake's answer]

Is it possible one could only add one barcode. I've analyzed how this works. I think the compiler runs two times, one time rendering the pstricks images. A second time inserting the images in the LaTeX pdf. However if I add two different barcodes. It simply overides the file by the last barcode, and uses this file for both the barcodes. Is there any workaround for this problem?

  • This question might be of some help. The answers seem to use pstricks though. – TH. Feb 8 '11 at 11:37
  • 1
    Indeed, but there it only compiles to .ps files. Of course one could write a simple bash script always converting the .ps file to a .pdf, but I was looking for a more elegant solution. – Willem Van Onsem Feb 8 '11 at 11:48
  • 1
    If you include the package auto-pst-pdf, you don't need to go through the conversion step. See my answer. – Jake Feb 8 '11 at 11:52
  • 1
    run it with xetex and you do not need the auto-pst-pdf package – user2478 Feb 8 '11 at 12:39
14

This will work directly with pdflatex:

\documentclass{article}
\usepackage{pst-barcode}
\usepackage{auto-pst-pdf}
\begin{document}
  \begin{pspicture}(0.7in,0.7in)
    \psbarcode{http://www.ctan.org}{}{qrcode}
  \end{pspicture}
\end{document}
  • Using this solution results in compiling without errors, but also without barcode. Is there perhaps a potential conflict between one of those packages? babel, amsmath, fullpage, amssymb, amsfonts, index, textcomp, graphicx, tikz, algorithm, algorithmic, wasysym, subfigure? – Willem Van Onsem Feb 8 '11 at 11:55
  • 3
    @CommuSoft: You need to run pdflatex with the -shell-escapre option, so that auto-pst-pdf can run the postscript tools. – Martin Scharrer Feb 8 '11 at 12:01
  • @CommuSoft: I don't have most of those packages installed on my system, so I don't know if there's a conflict. Try commenting the \usepackage lines one after the other until you find the offending package. – Jake Feb 8 '11 at 12:10
  • 1
    @martin Scharrer: that indeed did the job. The option to activate was --shell-escape (Linux/Ubuntu 10.10). Thanks. @Jake: I've try to find a conflict but none found. – Willem Van Onsem Feb 8 '11 at 12:18
  • 2
    The correct bounding box size is (0.7in,0.7in). the bar code has this default size. – user2478 Feb 8 '11 at 12:44
7

Take a look at possible packages for typesetting of barcodes at CTAN.

6

Two barcode side by side, run with pdflatex -shell-escape <file>

\documentclass{minimal}
\usepackage[pdf]{pstricks}
\usepackage{pst-barcode}
\begin{document}

\begin{pspicture}(0.7in,0.7in)
\psbarcode{ctan.org}{}{qrcode}
\end{pspicture}
%
\begin{pspicture}(0.7in,0.7in)
\psbarcode{tug.org}{}{qrcode}
\end{pspicture}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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