3

I'm using the CTAN QRcode package.

It works great with PDF, but unfortunately doesn't work at all for HTML.

Does anyone know if I'm doing something wrong or how I can force htlatex to use images for the QR codes?

pdflatex output: pdflatex qrcode

htlatex output viewed in Firefox: htlatex qrcode

TeX:

\section{Data}


\subsection{Electrum seed}

\begin{center}
\begin{longtable}{c}
\qrcode[height=1.5in,padding]{hawk pigeon horn badge amount engine math convince rural farm inhale mandate absorb} \newline
\end{longtable}
\LARGE{hawk pigeon horn badge amount engine math convince rural farm inhale mandate absorb}
\end{center}
3

tex4ht doesn't have configuration for \qrcode, but it is quite easy to make one. Configurations for packages are provided in packagename.4ht files, qrcode.4ht in our case:

\let\oldqrcode=\qrcode

\NewConfigure{qrcode}{2}

\renewcommand\qrcode[2][]{%
\a:qrcode%
\oldqrcode[#1]{#2}%
\b:qrcode%
}

\Configure{qrcode}
{\Picture+{}}
{\EndPicture}

first, old definition of \qrcode is saved, then configurable hooks named qrcode are declared, and \qrcode is redefined to insert hooks \a:qrcode and \b:qrcode around saved old contents of \qrcode.

The hooks are then configured with \Configure{qrcode}, \Picture+ and \EndPicture commands render content which is inside as image:

enter image description here

  • I was about to accept this answer but it has a huge problem: spaces are omitted in the htlatex output, scanning the code in your answer gives hawkpigeonhornbadgeamountenginemathconvinceruralfarminhalemandateabsorb while scanning the pdflatex code gives hawk pigeon horn badge amount engine math convince rural farm inhale mandate absorb. I replicated it on my machine too :( (If you do not have a smartphone with which to scan, you can use the command import :- | zbarimg :-) This answer will only work if your QR data contains no spaces. – Fredrick Brennan Jun 29 '15 at 10:28

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.