Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I've got a strange issue with the packages pstricks/pst-barcode and fancyhdr. Here is what I like to do: A custom header for every page, Name on the left, QR-code on the right.

Although the QR-code generated without any problems when I first tested it inside the page, it won't do if I put it into fancyheader. Although I searched and tried to find some solution for the last few hours, but I am still stucked. Does anybody know if here is an issue or a work around?

Errors are:

  • Warning line 1 Package auto-pst-pdf Warning: Creation of gesamt6-autopp.dvi failed

  • Warning line 1 Package auto-pst-pdf Warning: Could not create gesamt6-pics.pdf. Auxiliary files are not deleted.

Here is what the problematic code looks like (reduced):

\documentclass[11pt,a4paper]{scrlttr2}
\usepackage[english,ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{pst-barcode}
\usepackage[notightpage]{auto-pst-pdf}
\usepackage{pstricks}

\pagestyle{fancy}
\fancyhf{}

\newcommand\surname         {Somefamily}
\newcommand\firstname       {Somename}

\fancyhead[LO,LE]{\begin{textblock*}{80mm}(15mm,16mm)  \Huge{\firstname\ \surname} \end{textblock*}}

\rhead{
\begin{pspicture}(20mm,20mm)% save the space
\psbarcode{MECARD:N:\surname,\ \firstname;ADR:\street,\ \streetnumber,\ \zip,\ \country;TEL:\phoneprefix\phone;EMAIL:\mail;;}{eclevel=H width=1.0 height=1.0}{qrcode}
\end{pspicture}}

\begin{document}
Some text
\end{document}
share|improve this question
1  
If auto-pst-pdf does some automagic conversion of pstricks to pdf, then it well may choke on PSTricks in the header. I suggest to pre-generate the QR-code in a \savebox and \usebox that box in the header. –  Stephan Lehmke Sep 17 '12 at 12:07

2 Answers 2

As Stephan Lemke suggests, here is a working version:

\documentclass{article}
\usepackage{fancyhdr,textpos,lipsum,pst-barcode,auto-pst-pdf}
\pagestyle{fancy}
\fancyhf{}

\newcommand\surname{Somefamily}
\newcommand\firstname{Somename}
\newcommand\street{Somestreet}
\newcommand\zip{12345}
\newcommand\streetnumber{42}
\newcommand\country{Noland}
\newcommand\phoneprefix{555}
\newcommand\phone{555-5555}
\newcommand\mail{a@n.l}


% \fancyhead[L]{\begin{textblock*}{80mm}(15mm,16mm)  \Huge{\firstname\ \surname} \end{textblock*}}

\newsavebox{\CARD}

\fancyhead[R]{\usebox{\CARD}}

\setlength{\headheight}{77pt}

\begin{document}

\sbox{\CARD}{%
\begin{pspicture}(20mm,20mm)% save the space
\psbarcode{MECARD:N:\surname,\ \firstname;ADR:\street,\ \streetnumber,\ \zip,\ \country;%
  TEL:\phoneprefix\phone;EMAIL:\mail;;}{eclevel=H width=1.0 height=1.0}{qrcode}
\end{pspicture}}

\lipsum
\end{document}

Note that the box must be built after \begin{document}.

enter image description here

share|improve this answer

run it with xelatex and everything will be fine:

\documentclass[11pt,a4paper]{scrlttr2}
\usepackage{fontspec}
\setmainfont{Bera Serif}

\usepackage[english,ngerman]{babel}
\usepackage{fancyhdr}
\usepackage{pst-barcode,textpos}
\usepackage{pstricks}

\pagestyle{fancy}
\fancyhf{}

\newcommand\surname         {Somefamily}
\newcommand\firstname       {Somename}
\def\street{Street}
\def\streetnumber{12}
\def\zip{12345}
\def\country{USA}
\def\phoneprefix{001}
\def\phone{12346}
\def\mail{abc.org}

\fancyhead[LO,LE]{\begin{textblock*}{80mm}(15mm,16mm)  \Huge{\firstname\ \surname} \end{textblock*}}
\rhead{%
\begin{pspicture}(20mm,20mm)% save the space
\psbarcode{MECARD:N:\surname,\ \firstname;ADR:\street,\ \streetnumber,\ \zip,\ \country;TEL:\phoneprefix\phone;EMAIL:\mail;;}{eclevel=H width=1.0 height=1.0}{qrcode}
\end{pspicture}}

\begin{document}
Some text
\end{document}

enter image description here

share|improve this answer
    
Thanks to you all :) –  Ehmark Sep 17 '12 at 18:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.