Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am using eforms to create pdf where digital signature can be applied. Each document may have more than one digital signature field, ie so the document can be passed from person to person.

There is an added complexity here in the sense that depending on the parameters parsed to the custom command, \mySigField{...}, the username and title fields are either editable or not. In other words, the 4th and 5th argument represents the name and position respectively. If those input arguments are empty, an editable field is created, if they contain something, that something is printed and no editable field is created.

My Question is, in the event that there is at least one editable related field, how can I lock that field or fields once the particular user has signed.

The following sample output:

Output

is produced with the following code:

\documentclass{article}

\usepackage{varwidth}
\usepackage{hyperref}
\usepackage[pdftex]{eforms}
\usepackage{xcolor}
\usepackage{xifthen}

\def\colFeat{blue!50!black} %Feature Color 1 for Main Color Theme.

\makeatletter
    \def\eq@SigField{\centerWidget\eq@rectH
        \if\autoCenter n\eqcenterWidget=0pt\fi
        \leavevmode\hbox{\pdfstartlink user{\common@SigFieldCode}%
        \lower\eqcenterWidget\Bbox{\eq@rectW}{\eq@rectH}\pdfendlink}%
        \endgroup
    }
\makeatother

\newcommand{\mySigField}[5]{
    \begin{varwidth}{#2}
        \textcolor{\colFeat}{
            \fcolorbox{black!5!white}{black!5!white}{\sigField{#1}{#2}{#3}}\\[1mm]
            \rule{#2+3mm}{2pt}\\[2mm]
            \begin{tabular}{rl}
                \raggedleft Name: & \ifthenelse{\equal{#4}{}}{\TextField[name=name#1,width=6cm]{}}{#4}\\\\[-3mm]
                \raggedleft Position: & \ifthenelse{\equal{#5}{}}{\TextField[name=pos#1,width=6cm]{}} {#5}
            \end{tabular}
        }
    \end{varwidth}
}

\begin{document}
\def\WS{8cm}
\def\HS{2.5cm}
\section{Example of No Related Fields}
\mySigField{PERSONA}{\WS}{\HS}{John Smith}{Garbo}
\section{Example of One Related Field}
\mySigField{PERSONB}{\WS}{\HS}{Jane Doe}{}
\section{Example of Two Related Fields}
\mySigField{PERSONC}{\WS}{\HS}{}{}
\end{document}
share|improve this question
add comment

2 Answers

up vote 8 down vote accepted

According to the PDF specification (p. 446f), it is possible to specify the form fields that shouldn't be changed any more once a signature field has been signed in a so-called sigature field lock dictionary. With the eforms package, the code for your signature field in \mySigField to do this would be:

\sigField[\Lock{/Action/Include/Fields [(name#1)(pos#1)]}]{#1}{#2}{#3}

The names of the form fields that should be locked are given in round brackets. Other possible specifications are \Lock{/Action/All} to lock all form fields, and \Lock{/Action/Exclude/Fields [(field1)(field2)...]} to lock all fields apart from the specified ones.

In your example, the code above would specify non-existing form fields if one or both of the arguments for name and position are supplied, so it is possibly cleaner to use a series of conditions:

\ifthenelse{\equal{#4}{}}%
  {\ifthenelse{\equal{#5}{}}%
    {\sigField[\Lock{/Action/Include/Fields [(name#1)(pos#1)]}]{#1}{#2}{#3}}%
    {\sigField[\Lock{/Action/Include/Fields [(name#1)]}]{#1}{#2}{#3}}%
  }%
  {\ifthenelse{\equal{#5}{}}%
    {\sigField[\Lock{/Action/Include/Fields [(pos#1)]}]{#1}{#2}{#3}}%
    {\sigField{#1}{#2}{#3}}%
  }%

Unfortunately, I'm not able to test whether this works as expected, as I don't own Adobe Acrobat to actually fill one of the fields with a signature.

share|improve this answer
    
That works. I am going to post an answer below showing the final code, however, the result is yours... Many thanks. –  Nicholas Hamilton Jan 2 '13 at 13:19
add comment

I wanted to post the final code to this solution, which was provided by diabonas above.

I was able to either open this in adobe professional and sign, or alternatively, drag a file into a web browser and do the same. Presumably, this is because Adobe professional has taken my browser pdf plugin hostage.

Put in preamble:

\usepackage{eforms}
\makeatletter
    \def\eq@SigField{%
        \centerWidget\eq@rectH%
        \if\autoCenter n\eqcenterWidget=0pt\fi%
        \leavevmode\hbox{\pdfstartlink user{\common@SigFieldCode}%
                \lower\eqcenterWidget\Bbox{\eq@rectW}{\eq@rectH}\pdfendlink%
        }%
        \endgroup%
    }
\makeatother

\newcommand{\mySigField}[5]{
    \begin{varwidth}{#2}
        \textcolor{\colFeat}{
            \fcolorbox{black!5!white}{black!5!white}{
                \ifthenelse{\equal{#4}{}}%
                    {\ifthenelse{\equal{#5}{}}%
                        {\sigField[\Lock{/Action/Include/Fields [(name#1)(pos#1)]}]{#1}{#2}{#3}}%
                        {\sigField[\Lock{/Action/Include/Fields [(name#1)]}]{#1}{#2}{#3}}%
                    }%  
                    {\ifthenelse{\equal{#5}{}}%
                        {\sigField[\Lock{/Action/Include/Fields [(pos#1)]}]{#1}{#2}{#3}}%
                        {\sigField{#1}{#2}{#3}}%
                    }%
                }\\[1mm]            
            \rule{#2+3mm}{2pt}\\[2mm]
            \begin{tabular}{rl}
                \raggedleft Name: & \ifthenelse{\equal{#4}{}}{\TextField[name=name#1,width=6cm]{}}{#4}\\\\[-3mm]
                \raggedleft Position: & \ifthenelse{\equal{#5}{}}{\TextField[name=pos#1,width=6cm]{}} {#5}
            \end{tabular}
        }
    \end{varwidth}
}

Then in the actual document:

A signature field can be created with this command:

\mySigField{\KEY}{\HEIGHT}{\WIDTH}{\NAME}{\POSITION}

Noting that:

  • For multiple signatures, the \KEY should be defined and unique per signature block
  • \HEIGHT and \WIDTH ... Self Explanatory.
  • \NAME and \POSITION can either be left blank or filled in. If they are left blank, a field gets created which then gets locked when the final user signs. This is why the key needs to be unique, since the fields need to be linked to the signature.

Final Signature Panel Looks like This: Output

When Signed, Looks Like This. [The Fields Cannot be Changed] Output2

Finally, note that I have checked the behaviour with only one field, and that single field in either position. In both cases, everything locks off when signed.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.