I have a problem with SQL code in a PDF document. For code representation I'm using the listings
package. Everything works perfect until I copy-paste that code from the created PDF document. I get some phantom spaces in string type.
When people are reading my PDF document, they need to copy-paste some of the code. Visually the code looks good in PDF, but when I try to copy-paste my code to NotePad or any other editor I get some unexpected spaces in strings.
In the example below, when I copy-paste my SQL code, instead of getting:
SELECT ST_Area(the_geom)
FROM katastar
WHERE kc_broj = '1414';
I get
SELECT ST_Area(the_geom)
FROM katastar
WHERE kc_broj = ' 1414 ';
See the spaces in between quotes.
\documentclass{article}
\usepackage{listings,xcolor}
\lstset{
tabsize=4,
basicstyle=\scriptsize,
%upquote=false,
aboveskip=\baselineskip,
columns=fixed,
showstringspaces=false,
extendedchars=true,
breaklines=true,
prebreak = \raisebox{0ex}[0ex][0ex]{\ensuremath{\hookleftarrow}},
frame=single,
showtabs=false,
showspaces=false,
identifierstyle=\ttfamily,
keywordstyle=\color[rgb]{0,0,1},
commentstyle=\color[rgb]{0.133,0.545,0.133},
stringstyle=\color[rgb]{0.627,0.126,0.941},
language=SQL
}
\begin{document}
\begin{lstlisting}
SELECT ST_Area(the_geom)
FROM katastar
WHERE kc_broj = '1414';
\end{lstlisting}
\end{document}
SELECT S T _ A r e a ( t h e _ g e o m )
. As far as pdf viewer goes, I tried zathura, xpdf, evince and acroread with the exact same result. Converting the document withpdftotext
also produces the spaces.