14

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

enter image description here

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 is currently being updated.

UPDATE

Indeed, since Barcode Writer in Pure PostScript version 2014-01-06 the library generates 2D barcodes using filled paths as described in this answer.

UPDATE

This issue is resolved in pst-barcode 0.14.

loomi
  • 243
  • 6
    that is a problem with your viewer and not PSTricks. You have the wrong setting. –  Jul 10 '12 at 09: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 09: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
  • 1
  • @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
  • @loomi: pst-barcode was also updated. It always uses the same code –  Nov 19 '12 at 11:46
  • For relatively simple QR applications, there is qrcode.sty which uses TeX's \rule. – sgmoye Jun 25 '15 at 14:12

1 Answers1

13

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

enter image description here

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 09:58
  • the barcode is created as a matrix and your viewer thinks it is a bitmap image. Acrobat, okular, xpdf have no problem. –  Jul 10 '12 at 10:10
  • How do you know that 0.6cm is the exact value? – kiss my armpit Jul 10 '12 at 10:22
  • Hi Herbert, thanks for the response. What exactly is a Matrix in PS speak? Is there a way to let it draw as a bunch of paths? Or Convert it as such? Unfortunately I have no power about the viewer which is used for this problem. – loomi Jul 10 '12 at 10:55
  • @Higgs 0.6cm is just a value I use in my example, this should have no influence in the problem statement – loomi Jul 10 '12 at 10:56
  • 2
    @loomi: you should write to the barcodewriter mailing list, see http://code.google.com/p/postscriptbarcode/ –  Jul 10 '12 at 11:21
  • @Higgs, Thanks for the link, just today a certain Thomas did open an Issue there. Waiting for the response there. As the implementation of the Maxicode shows. It should be possible. – loomi Jul 10 '12 at 11:53
  • @loomi: Higgs =/= Herbert. – kiss my armpit Jul 10 '12 at 11:58
  • Uhhh sorry to Higgs and Herbert (-, – loomi Jul 10 '12 at 12:05
  • I am the "certain" Thomas. Funny how things go in parallel sometimes. I do not have the expertise to recode the 2D rendering codes on a vector basis in PS I have to admit. Nevertheless it would be better for some not well behaving viewers. – GorillaPatch Jul 10 '12 at 17:17
  • 1
    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
  • I processed the above code as suggested and when opening the .pdf, got an imagemask which is reported as 25 x 25 pixels at 36 ppi. Opening the file in Adobe Illustrator did not yield any vector paths. – WillAdams Aug 12 '13 at 14:32