% Context file
% Filename: XY-arrange-test.tex
% Willi Egger
% 13-09-2008
% Copyright (c) 2008 BOEDE. All rights reserved.

\showframe

\definepapersize[Etiket][height=42.3mm,width=105mm]
\setuppapersize [Etiket][A4,portrait]
\setuppaper
    [topspace=0mm,
    backspace=0mm,
    dx=2mm,
    dy=0mm,
    nx=2,
    ny=7,
    margin=0,
    width=210mm,
    height=297mm]
\setuplayout
    [topspace=4mm,
    backspace=6mm,
    margin=0mm,
    width=96mm,
    height=34mm,
    header=0mm,
    footer=0mm]
\setuparranging[XY]
\definelayer[Etiket][width=\textwidth, height=\textheight]
\setupframedtexts[frame=off,width=\textwidth,align=right]

\def\Printlabel{8} %Last available label
\def\Labels{14} %Total number of labels

\startbuffer[Adr\Printlabel]
  \framedtext[frame=off]{%
		\startlines
			Mr. Klaus Freiner
			Kingston Road
			358766 Arranged Address		
			XY Arrangement
		\stoplines}
\stopbuffer

\startbuffer[Retouradres]
	\framed[frame=off,bottomframe=on,rulethickness=2pt]{%
		Willi Egger, Maasstraat 2, {\sc 5836 BB Sambeek, Nederland }}
\stopbuffer

\starttext
\dostepwiserecurse{1}{\Labels}{1}{%
    \ifnum\recurselevel=\Printlabel
    {\setlayer
		[Etiket]
		[preset=lefttop,location={right,bottom}]
		{\switchtobodyfont[5pt]\getbuffer[Retouradres]}
    \setlayer
		[Etiket]
		[preset=leftbottom,location={right,top},y=-3mm,x=-3mm]
		{\switchtobodyfont[10pt]\getbuffer[Adr\recurselevel]}}
    \else
    {\setlayer
      [Etiket]
      [preset=lefttop,location={right,bottom}]
      {\strut}}
    \fi
    \placelayer[Etiket]}
\stoptext