5

Here is what I'm working with:

\documentclass{letter}

\newcommand*{\BottomLeftX}{1.0in+\hoffset+\oddsidemargin}%
\newcommand*{\BottomLeftY}{\paperheight-1.0in-\voffset-\topmargin-\headheight-\headsep-\textheight}%

\newcommand*{\AbsolutePosition}[4][]{%
    % #1 = tikz options
    % #2 = x (from south west corner of page
    % #3 = y
    % #4 = text
    \begin{tikzpicture}[overlay, ultra thick]
        %\draw [shift={(#2,#3)},#1]  (current page.south west) circle (2pt) 
        \draw [#1]  ($(current page.south west) + (\BottomLeftX,\BottomLeftY) + (#2,#3)$) 
            %circle (2pt) %  adding `[opacity=0.2]` to the node below will let you see this reference point
                node[] {#4};
    \end{tikzpicture}%
}

\usepackage{float}
\usepackage[english]{babel}
\usepackage{fix-cm} 
\usepackage{marvosym}
\usepackage{auto-pst-pdf,pst-barcode}
\usepackage{background}
\usepackage{amsmath}
\usepackage{ textcomp }
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{textpos}
\usepackage{pstricks}
\backgroundsetup{%
  scale=2,       %% change accordingly
  angle=0,       %% change accordingly
  opacity=.2,    %% change accordingly
  color =black,  %% change accordingly
  contents={\begin{tikzpicture}[remember picture,overlay]
        \node at ([yshift=-5pt,xshift=0pt]current page.center) {\includegraphics[width=5cm]{filmax.jpg}};
    \end{tikzpicture}}
}
\usepackage[usestackEOL]{stackengine}
\edef\tmpbs{\the\baselineskip}
\setstackgap{L}{\tmpbs}
\newlength\tmpwd
\newlength\tmpht
\usepackage{invoice}
\fboxrule=1pt

\let\svaddress\address
\renewcommand\address[2][]{%
  \ifx\relax#1\relax\svaddress{#2}\else
  \def\theaddress{#2}\invoicenote{#1}\fi}

\def\invoicenote#1{%
  \def\stackalignment{l}
  \setbox0=\hbox{\expandafter\Longstack\expandafter{\theaddress}}
  \tmpwd=\wd0\relax
  \tmpht=1.5cm %\ht0\relax
  \def\y{\fboxsep=0pt\fbox{\rule{0pt}{\tmpht}%
    \stackon[\tmpht-\tmpbs]{\rule{\dimexpr\textwidth-\tmpwd-3cm\relax}{0pt}}%
    {\hspace{0.23cm}~\textsf{\strut {\color{red}INVOICE}}~~\smash{\Longunderstack{#1}}}}}
  \svaddress{\llap{\y\hspace{0.31cm}}\expandafter\Longstack\expandafter{\theaddress}}
}

%  ANY OF THESE FORMS WILL WORK:
%\address{\emph{Invoice from:} \\ My Address \\ My Address \\ My Address}
%\address[~]{\emph{Invoice from:} \\ My Address \\ My Address \\ My Address}
\address[\footnotesize Attention to: \hspace{0.15cm}Master of Provisions\\ \footnotesize Your Ref.\textnumero:\\ \footnotesize Our Ref.\textnumero:\\ \footnotesize Credit Terms: NET 15]{\emph{Invoice from:} \\ {\tiny My Address} \\ My Address \\ My Address}

\signature{Tin Tin}
\date{Hong Kong, Thu Apr 24 2014}
\begin{document}
  \begin{letter}{\emph{Invoice to:} \\ {\tiny To Address} \\ To Address \\ To Address}
    \opening{Invoice no. 0000000001}
    Hello, and good evening\footnote{My representative's name is Georges Prosper Remi.}.
    \begin{invoice}{USD}{0}
      \ProjectTitle{Invoice}%
      \Fee{Database Maintenance} {12999.99} {1}
      \AbsolutePosition[fill=red,draw=red]{4.1cm}{-7.21cm}{\includegraphics[scale=0.5]{sig.png}}
    \end{invoice}
    \closing{\emph{Invoice Release Authorization:}}
\vspace{0cm}
%\begin{pspicture}(0.5in,0.5in)\psbarcode{0000000001}{eclevel=L}{qrcode}\end{pspicture}\hspace{5cm}
 %\includegraphics[scale=0.3]{foot.png}
\fbox{
    \parbox{11.54cm}{
        ~\textsf{{\color{red}COMMENTS}}
        \vspace{1.5cm}

        \hspace{9.25cm}{\tiny Master of Provisions}
    }
}
\begin{textblock}{10}(-0.5,1.25)
\centering
Thank you for your business. \\ \vspace{0.5cm}\fontsize{10}{10}\selectfont {\Large\Letter} tintin@ics.ch \hspace{0.2cm} {\Large\Telefon} +1 (555) 555 - 5555
\end{textblock}
  \end{letter}
\end{document}

Below the last "My Address" and the last "To Address" I would like to have a "Royal Mail" barcode just below each; that is, \psbarcode. How can this be achieved with my existing, albeit wild, layout?

  • Have you tried adding \psbarcode{MYADDRESS}{}{royalmail}? – Werner Apr 25 '14 at 5:07
  • @Werner, yes, it doesn't show up. – The South Face Apr 25 '14 at 5:09
  • @TheSouthFace: You are mixing the use of pstricks and tikz. Are you adding the --shell-escape option to your compile sequence? – Werner Apr 25 '14 at 5:34
  • @Werner, what does that mean? And, most likely, no... – The South Face Apr 25 '14 at 6:49
  • In order to use pstricks, you typically need to use latex. In order to use tikz you typically use pdflatex. So you can't use both. However, pstricks provides the ability to function under pdflatex by means of auto-pst-pdf. In order to do this, all pstricks images are written to file as a stand-alone pspicture, compiled under latex and converted to PDF for inclusion in your original document as a pre-compiled image. That interruption in your compilation requires you to supply the command-line option --shell-escape when compiling. – Werner Apr 25 '14 at 6:54
2

There is a bug in current tikZ of TL 2013. You need to seperate loading of tikZ and PSTricks. With pdflatex --shell-escape <file>:

\documentclass{letter}
\usepackage{mwe}%%%% for the demo images
\newcommand*{\BottomLeftX}{1.0in+\hoffset+\oddsidemargin}%
\newcommand*{\BottomLeftY}{\paperheight-1.0in-\voffset-\topmargin-\headheight-\headsep-\textheight}%

\newcommand*{\AbsolutePosition}[4][]{%
    % #1 = tikz options
    % #2 = x (from south west corner of page
    % #3 = y
    % #4 = text
    \begin{tikzpicture}[overlay, ultra thick]
        %\draw [shift={(#2,#3)},#1]  (current page.south west) circle (2pt) 
        \draw [#1]  ($(current page.south west) + (\BottomLeftX,\BottomLeftY) + (#2,#3)$) 
            %circle (2pt) %  adding `[opacity=0.2]` to the node below will let you see this reference point
                node[] {#4};
    \end{tikzpicture}%
}

\usepackage[english]{babel}
\usepackage{fix-cm} 
\usepackage{marvosym}
\usepackage{auto-pst-pdf}
\ifpdf
  \usepackage{tikz}
  \usetikzlibrary{calc}
  \usepackage{background}
  \backgroundsetup{%
    scale=2,       %% change accordingly
    angle=0,       %% change accordingly
    opacity=.2,    %% change accordingly
    color =black,  %% change accordingly
    contents={\begin{tikzpicture}[remember picture,overlay]
        \node at ([yshift=-5pt,xshift=0pt]current page.center) {\includegraphics[width=5cm]{example-image-a}};
    \end{tikzpicture}}
}
\else
  \usepackage{pst-barcode}
\fi
\usepackage{amsmath}
\usepackage{ textcomp }
\usepackage{textpos}
\usepackage[usestackEOL]{stackengine}
\edef\tmpbs{\the\baselineskip}
\setstackgap{L}{\tmpbs}
\newlength\tmpwd
\newlength\tmpht
\usepackage{invoice}
\fboxrule=1pt

\let\svaddress\address
\renewcommand\address[2][]{%
  \ifx\relax#1\relax\svaddress{#2}\else
  \def\theaddress{#2}\invoicenote{#1}\fi}

\def\invoicenote#1{%
  \def\stackalignment{l}
  \setbox0=\hbox{\expandafter\Longstack\expandafter{\theaddress}}
  \tmpwd=\wd0\relax
  \tmpht=1.5cm %\ht0\relax
  \def\y{\fboxsep=0pt\fbox{\rule{0pt}{\tmpht}%
    \stackon[\tmpht-\tmpbs]{\rule{\dimexpr\textwidth-\tmpwd-3cm\relax}{0pt}}%
    {\hspace{0.23cm}~\textsf{\strut {\color{red}INVOICE}}~~\smash{\Longunderstack{#1}}}}}
  \svaddress{\llap{\y\hspace{0.31cm}}\expandafter\Longstack\expandafter{\theaddress}}
}

%  ANY OF THESE FORMS WILL WORK:
%\address{\emph{Invoice from:} \\ My Address \\ My Address \\ My Address}
%\address[~]{\emph{Invoice from:} \\ My Address \\ My Address \\ My Address}
\address[\footnotesize Attention to: \hspace{0.15cm}Master of Provisions\\ \footnotesize Your Ref.\textnumero:\\ \footnotesize Our Ref.\textnumero:\\ \footnotesize Credit Terms: NET 15]{\emph{Invoice from:} \\ {\tiny My Address} \\ My Address \\ My Address}

\signature{Tin Tin}
\date{Hong Kong, Thu Apr 24 2014}
\begin{document}
  \begin{letter}{\emph{Invoice to:} \\ {\tiny To Address} \\ To Address \\ To Address}
    \opening{Invoice no. 0000000001}
    Hello, and good evening\footnote{My representative's name is Georges Prosper Remi.}.
    \begin{invoice}{USD}{0}
      \ProjectTitle{Invoice}%
      \Fee{Database Maintenance} {12999.99} {1}
      \AbsolutePosition[fill=red,draw=red]{4.1cm}{-7.21cm}{\includegraphics[scale=0.5]{example-image-a}}
    \end{invoice}
    \closing{\emph{Invoice Release Authorization:}}
\vspace{0cm}
\begin{pspicture}(0.5in,0.5in)
\psbarcode{0000000001}{eclevel=L}{qrcode}
\end{pspicture}\hfill
%\includegraphics[scale=0.3]{foot.png}
\fbox{%
    \parbox{10cm}{%
        ~\textsf{{\color{red}COMMENTS}}
        \vspace{1.5cm}

        \hspace{9.25cm}{\tiny Master of Provisions}
    }
}
\begin{textblock}{10}(-0.5,1.25)
\centering
Thank you for your business. \\ \vspace{0.5cm}\fontsize{10}{10}\selectfont {\Large\Letter} tintin@ics.ch \hspace{0.2cm} {\Large\Telefon} +1 (555) 555 - 5555
\end{textblock}
  \end{letter}
\end{document}

enter image description here

Using xelatex makes live easier, no need for using auto-pst-pdf:

[ ... ]
\usepackage[english]{babel}
\usepackage{fix-cm} 
\usepackage{marvosym}
  \usepackage{tikz}
  \usetikzlibrary{calc}
  \usepackage{background}
  \backgroundsetup{%
    scale=2,       %% change accordingly
    angle=0,       %% change accordingly
    opacity=.2,    %% change accordingly
    color =black,  %% change accordingly
    contents={\begin{tikzpicture}[remember picture,overlay]
        \node at ([yshift=-5pt,xshift=0pt]current page.center) {\includegraphics[width=5cm]{example-image-a}};
    \end{tikzpicture}}
}
  \usepackage{pst-barcode}
\usepackage{amsmath}
[ ... ]

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.