# [texhax] PDF forms: fill in textfield once, show its contents often throughout document

Susan Dittmar Susan.Dittmar at gmx.de
Fri Nov 15 19:05:49 CET 2013

Hi folks,

after days of searching the 'net and trying to wrap my mind around the problem,
I come to you in hope one of you might have a good idea for me.

I would like to generate a PDF document with textfields that can be filled in by
the user (that part works). What I don't know how to archive is that I want the
user-supplied contents to be displayed at several places thoughout the document,
preferably without further user action. And to ease writing, I want those
repetitions provided by a macro.

I certainly don't have a _working_ minimal example, but I hacked together my
rough ideas in case someone wants a starting point for development. But please
don't feel restricted by its form or choice of packages! I might well have run
into a mental cul-de-sac.

Any suggestions welcome!

Susan

\documentclass{article}
\usepackage[pdftex]{hyperref}   % probably pdftex option is not needed

\usepackage[pdftex]{insdljs}    % probably pdftex option is not needed
\begin{insDLJS}[test]{test}{JavaScript}
% whatever callbacks might be needed...
\end{insDLJS}

%% no idea if this really must be here:
%\OpenAction{/S/JavaScript/JS(docOpen();)}

\begin{document}

Here's the master textfield:
\TextField[name={FirstName}, value={Susan}, width=9em]{}%

% a command to display the master textfield's contents
% (this.getField("FirstName").value):
\newcounter{DisplayFirstNameCount}
\setcounter{DisplayFirstNameCount}{0}
\newcommand{\DisplayFirstName}{%
% No idea how to access this.getField("FirstName").value here.
% I probably need another (readonly) textfield and some callbacks:
\stepcounter{DisplayFirstNameCount}
\TextField[name={FirstName\theDisplayFirstNameCount},
% <--- what to put in here???