# How to include online postage in a scrlttr2 letter?

The class scrlttr2 is well suited for using window envelopes by default. That means that it prints the address at the standardized position.

In Germany, you can buy online postage which is supposed to be printed on the envelope or on the letter into the window area next to the address.

Using the window area is of course more convenient.

The German Post Office ('Deutsche Post') only provides an integration for Microsoft Word (of course ;)).

Thus my question: How to include online postage in a scrlttr2 document?

The online postage is available at the Deutsche Post. I used the output format 'DIN A4 Normalpapier (Einlegeblatt)' (which is only available if a recipient is entered - a single character will do). You can get a sample file there. Since the page is in german I put the resulting sample PDF-file also on a private web-server.

The standardized position of the window is well explained in Wikipedia - the article is in german, but the figure contains all the information.

-
@maxschlepzip You have not accepted or given feed back on the answers. In none of them satisfying, and in case, what is the problems? Maybe we can improve the answers! –  Sveinung Jul 10 '12 at 14:05
@Sveinung, I gave feedback on Jake's comment - first I've waited for him posting an answer - now I see your answer which is probably even more convenient. I have to test your approach. –  maxschlepzig Jul 10 '12 at 16:06

Another possibiltiy is to use tikz:

\documentclass[a4paper]{scrlttr2}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{graphicx}
\usepackage{tikz}
\setkomavar{fromname}{John Doe}
\begin{document}
\begin{letter}{%
Jane X\\
456 Fake Village
}
\begin{tikzpicture}[remember picture, overlay]
\node [xshift=65mm,yshift=-60mm] at (current page.north west)
[below right]
{\includegraphics[trim=57mm 228mm 114mm 55mm,clip]{pstge.pdf}} ;
\end{tikzpicture}
\opening{Sehr geehrte Damen und Herren,}
\closing{Mit freundlichen Grüßen}
\end{letter}
\end{document}


Advantage: Easy to place the postage absolutely.

Disadvantage: You have to compile the document 2 times.

-
Very nice! To avoid compiling twice, instead of using TikZ for the absolute placement, you could also use the eso-pic package, which is included in TeX Live. If you load it using \usepackage[colorgrid,gridunit=mm,texcoord]{eso-pic}, you can place the postage stamp using \AddToShipoutPictureBG*{ \put(\LenToUnit{66mm},\LenToUnit{-75mm}){ \includegraphics[trim=57mm 228mm 114mm 55mm,clip]{postage_sample.pdf} } }, with a grid to help you find the right position. You can then switch off the grid by setting colorgrid=false. –  Jake Jul 6 '12 at 9:56
@Jake, if you post this as answer I'll upvote (and perhaps accept it). –  maxschlepzig Jul 6 '12 at 12:36

It looks like you can solve this by using KOMA-script options and internal commands. Please, have a look at the following MWE:

\documentclass[addrfield=backgroundimage,%
fontsize=12pt, UKenglish]%
{scrlttr2}
\usepackage{babel,graphicx}
\usepackage[utf8]{inputenc}

trim=5mm 228mm 114mm 55mm,clip]%
{postage_sample.pdf}}

\begin{document}
\begin{letter}{Name and \\ Address \\ of \\ Recipient}

\opening{Hello}

\closing{Kind regards}

\end{letter}
\end{document}


To change the horizontal and vertical placement of the image, change the first and last parameter (i.e. change the values 5mm or 55mm until it fit).

I have not analysed if this may have unintended side effects.

-
Unfortunately, addrfield does not work together with backaddress - i.e. when using addrfield=backgroundimage the backaddress in the window area is disabled. Also I would need to shift the included graphics by ~ (-5mm,-5mm) to fit it into the window area. –  maxschlepzig Jul 16 '12 at 12:40
@maxschlepzig Shifting the graphics in a minor problem: \setkomavar{addresseeimage}{\includegraphics[trim=0mm 228mm 114mm 45mm,clip]{postage_sample.pdf}} shift it 5 mm to the left and 5 mm down. I will look into the manual to see if it is possible to enable back address. –  Sveinung Jul 17 '12 at 6:38

Inspired by a blog entry I checked out the package picins:

\documentclass[a4paper]{scrlttr2}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{graphicx}
\usepackage{picins}
\setkomavar{fromname}{John Doe}
\begin{document}
\begin{letter}{%
\parpic[r]{\includegraphics[trim=57mm 228mm 114mm 55mm,clip]{pstge.pdf}}
Jane X\\
456 Fake Village
}
\opening{Sehr geehrte Damen und Herren,}
\closing{Mit freundlichen Grüßen}
\end{letter}
\end{document}


Where pstge.pdf denotes the sample online postage PDF-file.

Disadavantage: picins.sty is not available on current TeX-Distributions (e.g. TeXLive).

-

I simply take a two step approach:

1. TeXing the letter without address and printing.
2. Using the software (which does no longer works i think) or the website to print the stamp with address using 'DIN A4 Normalpapier (Einlegeblatt)'

There are some older discussions on d.c.t.t.:

StampIt in LaTeX?

Briefe mit STAMPIT frankieren

-

Using the eso-pic suggestion by Jake the example looks like this:

\documentclass[a4paper]{scrlttr2}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage[texcoord]{eso-pic}
\usepackage{graphicx}
\setkomavar{fromname}{John Doe}
\newcommand{\includepostage}[1]{%
\put(\LenToUnit{60mm},\LenToUnit{-70mm}){%
\includegraphics[trim=57mm 228mm 114mm 55mm,clip]{#1}}}}
\begin{document}
\begin{letter}{%
Jane X\\
456 Fake Village
}
\includepostage{postage.pdf}
\opening{Sehr geehrte Damen und Herren,}
\closing{Mit freundlichen Grüßen}
\end{letter}
\end{document}