# How to produce Latex QR-Code (or in general 2d codes) as Vector graphic?

The pst-barcode package is great to produce bar-codes in all flavors.

And it does 1d bar-codes like a charm. Also it is capable of generating 2d bar-codes with a command like this for a qrcode:

  \begin{pspicture}(0.6cm,0.6cm)
\psbarcode{http://example.org}{eclevel=L}{qrcode}
\end{pspicture}


Which renders into something like this

But unfortunately all 2d codes are generated as bitmaps images. And depending on your viewer the end product gets fuzzy borders as the example shows.

Is there a way to create real vector graphics like the 1d bar-codes are generated?

UPDATE

It is true that the aliasing of the 2d codes is only a problem in some viewers and nevertheless it is printed correctly. The problem comes from the underlying postscript code which generates the 2d codes as an image in postscript. It should be possible to generate 2d codes also by using paths like the MaxiCode implementation. The underlying code code is currently being updated. If you are interested in a solution head over star the issue and help with testing.

-
that is a problem with your viewer and not PSTricks. You have the wrong setting. –  Herbert Jul 10 '12 at 9:30
The example is from Preview on Mac OS X. Sure the aliasing comes from the viewer. This is normal for bitmap images. What I are looking for is a vector representation of the barcode. The other barcodes render nicely in all viewers. (What has to be possible also for qrcodes.) –  loomi Jul 10 '12 at 9:54
If I look at the generated image with Preview or Skim the blurring is there; not if I use xpdf. –  egreg Jul 10 '12 at 10:04
possible duplicate of Deactivating Anti-Aliasing when typesetting QR-Code –  Jake Jul 10 '12 at 10:25
@Jake Yes it is kind of a duplicate. Just that with pictures you have no chance to push the viewer not to use aliasing. In this case for QR-Codes it should be possible to draw this code in a way it will look sharp also in viewer which do aliasing of images. –  loomi Jul 10 '12 at 10:59
show 1 more comment

PSTricks always creates vector orientated graphics. With

\documentclass{article}
\usepackage{auto-pst-pdf,pst-barcode}
\begin{document}

\begin{pspicture}(1in,1in)
\psbarcode{http://example.org}{eclevel=L}{qrcode}
\end{pspicture}

\end{document}


and running pdflatex -shell-escape <file> I'll get

The same is possible with xelatex whithout package auto-pst-pdf or with latex->dvips->ps2pdf

-
Hmm my TeXShop uses pdflatex --file-line-error --shell-escape --synctex=1 so i think the problem is somewhere else? Also the official pst-barcode documentation has the 2d bar-codes not as vector graphic included. Can you attach the pdf? –  loomi Jul 10 '12 at 9:58
the barcode is created as a matrix and your viewer thinks it is a bitmap image. Acrobat, okular, xpdf have no problem. –  Herbert Jul 10 '12 at 10:10
How do you know that 0.6cm is the exact value? –  I am who I say I am Jul 10 '12 at 10:22
@loomi: you should write to the barcodewriter mailing list, see code.google.com/p/postscriptbarcode –  Herbert Jul 10 '12 at 11:21
True, I have neither the experience nor the time to do this change. If there is a PostScript speaking person reading this, the task would be to change the code from using imagemask to using paths. The author Terry Burton would have some pointers where to start. Basically you have to rewrite the /renmatrix to take a bunch of pixels and draw them one by on. –  loomi Jul 10 '12 at 18:20