21

My system generates LaTex letters and templates; however, my client has to fill out pre-built forms that they have no control over. I'd like to fill out these forms by measuring the coordinates in mm and then placing text using those coordinates in mm as the starting point. I can then print directly on top of the existing paper forms.

Ideally I'd like the LaTeX to function something like below:

\command{x coordinate}{y coordinate}{text1}\\
\command{x coordinate}{y coordinate}{text2}\\
\command{x coordinate}{y coordinate}{text3}\\
\command{x coordinate}{y coordinate}{text4}\\
\command{x coordinate}{y coordinate}{text5}\\
\command{x coordinate}{y coordinate}{text6}\\

In the event the customer form changes I can just change the coordinates. Is this approach possible?

Adam Liter
  • 12,567
Jim
  • 213

2 Answers2

25

One option using TikZ. All distances are measured from the upper left corner of the paper (this can be easily modified to choose another origin point):

\documentclass{article}
\usepackage{tikz}

\newcommand\PlaceText[3]{%
\begin{tikzpicture}[remember picture,overlay]
\node[outer sep=0pt,inner sep=0pt,anchor=south west] 
  at ([xshift=#1,yshift=-#2]current page.north west) {#3};
\end{tikzpicture}%
}

\begin{document}

\PlaceText{20mm}{30mm}{First text}
\PlaceText{50mm}{30mm}{Second text}
\PlaceText{60mm}{70mm}{Third text}

\end{document}

enter image description here

Gonzalo Medina
  • 505,128
15

With textpos:

\documentclass[a4paper]{article}
\usepackage[overlay,absolute]{textpos}
\newcommand\PlaceText[3]{%
\begin{textblock*}{10in}(#1,#2)  %% change width of box from 10in as you wish
#3
\end{textblock*}
}%
\textblockorigin{-5mm}{0mm}   %% Default origin top left corner and it can be changed in this line
\begin{document}
\PlaceText{0mm}{0mm}{Origin}
\PlaceText{20mm}{30mm}{First text}
\PlaceText{50mm}{30mm}{Second text}
\PlaceText{60mm}{70mm}{Third text}

\end{document}

enter image description here