When I use \qrcode, the resulting QR code image has blank lines running through it, leading to difficulty of my phone reading the QR code. Does anybody know how to remedy it? I've tried pdfLatex as well as XeLatex, and both lead to the same distorted image. enter image description here


1 inch high (and wide):

  • 3
    looks ok here. Which reader did you use? Feb 21 at 9:30
  • 2
    There are several duplicates around: this is a problem in the PDF viewer, I fear. this is what I have with okular: i.stack.imgur.com/XaBCZ.png
    – Rmano
    Feb 21 at 9:31
  • I haven't tried viewing a formal PDF of it in Adobe or Chrome....this is how it appears in the PDF viewer of MikTex Feb 21 at 14:34
  • Maybe you can try to use this answer to add a bit of overlap to the rules... I have no time now, but I'll try to give it a shot over the week-end if nobody steps in.
    – Rmano
    Feb 22 at 9:37
  • 1
    The weird thing is that the white lines are not between the modules as one could expect if it was just a rounding problem with the module sizes/coordinates, but inside them (you can see a thin black line to the right of the white line when there is no black module).
    – jcaron
    Feb 22 at 12:20

2 Answers 2


I think this is a problem with the viewer; it is shown in several questions in the site (here, here, here).

Probably, it could be circumvented in the package by programming a bit of overlap in the black squares (you could check with the author). Another possibility is to take charge of the PDF->pixel conversion. You can for example convert to png, blur a bit, and then resample...


This as seen by Firefox (pdf.js) as:

enter image description here

where you can see the thin lines. You can process it with ImageMagick:

convert -density 600 -blur 0.5x1 lilla.pdf -resample 300 -sharpen 0x0.5 lilla.png

and then Firefox will show it as:

enter image description here

(You need to play with the parameters to have a better result...)

  • Thank you so much. The problem is that I'm having the QR code directly in a XeLaTeX document (it's a verification QR code that I want to issue on each prescription I give to patients for the pharmacies). Feb 21 at 14:36
  • Rather than blurring which gives a pretty nasty result IMHO, just displaying the same QR Code twice at nearly the same position, but with a very small offset, would probably give a better result? Provided the "white" modules are actually transparent, of course.
    – jcaron
    Feb 22 at 12:23
  • @jcaron maybe... you can do some kind of "darken only" composition even if they are not transparent, I suppose.
    – Rmano
    Feb 22 at 13:03

Alternatively, you can use PSTricks package pst-barcode. It seems to produce better results and provides a vast variety of different bar and QR code types.

Typeset with lualatex:


default (1 inch height):\quad

Screenshot from Firefox at 400% zoom from a 1920x1080 screen:

enter image description here

Another option could be patching qrcode. It builds upon LaTeX's


command. The visible hairlines between adjacent modules can be avoided by allowing some overlap between them, as suggested by Rmano.

Here, TikZ is used to re-implement the standard \rule with a filled rectangle whose border is also drawn:



    \clip (0,0) rectangle (1,1);
    \ifdim #2>0pt\ifdim #3>0pt \filldraw (0,0) rectangle (1,1); \fi\fi

  • Yes, this seems to survive the antics of the viewers better...
    – Rmano
    Feb 21 at 14:51

You must log in to answer this question.

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