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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to create a LaTeX document that when rendered into PDF, has forms that can be filled out using Adobe Reader or other such programs. Then I'd like to be able to extract the data. I deliberately would like to avoid using Acrobat for all the usual reasons (non-free, need different versions for different platforms etc).

Can this be done ?

share|improve this question
Creating a PDF form using pdflatex should be possible. However the "Then I'd like to be able to extract the data" part is then only a PDF issue. IIRC the PDF can be transmit the form to a web server. How exactly do you want to extract the data? – Martin Scharrer Apr 3 '11 at 15:21
@Suresh Try this post tex.stackexchange.com/questions/7869/…, if this is what you are looking post a comment and I will add some explanations. Also search the JavaScript tag. – Yiannis Lazarides Apr 3 '11 at 15:23
@Yiannis: that's an interesting trick. Makes me think though that I should give up on the latex and just use HTML + javascript. @Martin, even extracting to a text file would be fine. – Suresh Apr 3 '11 at 15:27
@Suresh Best option would be in this case -- and I hate to say so to actually buy Acrobat Professional. It can do all these much easier transmit to the web collate the data etc... – Yiannis Lazarides Apr 3 '11 at 15:33
@Yiannis that just makes me sad :) – Suresh Apr 3 '11 at 15:49
up vote 69 down vote accepted

The hyperref package provides a method to create PDF forms. They way I understand it the form is either to be printed or to be transmitted to a webserver like a HTML form.

Here a small example:




    \TextField{Name} \\\\
    \CheckBox[width=1em]{Check} \\\\




share|improve this answer
while both answers are great, this one is closer to what I need because it allows extraction of the data via a CGI script. – Suresh Apr 3 '11 at 15:48
@Suresh: Give it a few hours (to see if there is another solution), then accept this one if it's still the best approach for you. – Joseph Wright Apr 3 '11 at 15:51
yes, I was planning to wait a bit. I just wanted to clarify the things that were more important (extraction being one) – Suresh Apr 3 '11 at 15:54
I've just created an example: martin-thoma.com/creating-pdf-forms-with-latex – Martin Thoma Mar 3 '12 at 6:35
Does this work for local files? I.E. can I set the action of this to a local $.cgi$ file? – Goodies Mar 27 '15 at 17:56

Here is some code that I use to create forms that can be either printed and filled out with a pen or filled out electronically in a PDF viewer. When printed, the form provides a line for each form field. Like Martin Scharrer's solution I'm using the hyperref package. The tricky bit was to define an input field of a given length (here textwidth minus 4 cm). It required to override the \LayoutTextField hook.



\def\LayoutTextField#1#2{#2} % override default in hyperref

\def\lbl#1{\hbox to 4cm{#1\dotfill\strut}}%

\def\q#1{\hbox to \hsize{\labelline{#1}{\longline}}\vskip1.4ex}

    \q{First Name}
    \q{Last Name}

enter image description here

In a PDF viewer each line becomes a form field.

share|improve this answer
To turn off red boxes: \def\labelline#1#2{\lbl{#1}\vbox{\hbox{\TextField[name=#1,width=#2,borderwidth=‌​0]{\null}}\kern0pt\hrule}}. – Adobe Jul 8 '13 at 17:27
This command from @Adobe comment does not work for me. It compiles only if i exclude borderwidth=0. Any other tips on "turnning of red boxes"? – Dr Beco Aug 25 '15 at 3:47
@DrBeco : For some reason copypasting Adobe's line doesn't seem to work indeed. Just add ,borderwidth=‌​0 in Christian's original code. – Skippy le Grand Gourou Sep 18 '15 at 9:17

I've used the eforms package, which is used by DANTE for their membership form (which of course I can't now locate in .tex format!). You'll probably have to download and unpack eforms from CTAN yourself, as it's not in TeX Live (unpack eforms, insdljs and taborder, all in the eforms bundle). A short example from a registration form I've done:


% From DANTE's registration form!

    \kern 4 pt

   Title                 & \infoInput{Title}\\[6pt]
   First name            & \infoInput{Firstname}\\[6pt]
   Last name             & \infoInput{Surname}\\[6pt]
   E-mail address        & \infoInput{Email}\\[6pt]
   Dietary requirements  & \infoInput{Dietary}\\[6pt]

  Student (\pounds60) 
    & \raisebox{.75ex}{\radioButton{RegType}{10bp}{10bp}{Student}} 
  Academic/post-doc (\pounds120)
    & \raisebox{.75ex}{\radioButton{RegType}{10bp}{10bp}{Academic}} 
  Industrial (\pounds180)
    & \raisebox{.75ex}{\radioButton{RegType}{10bp}{10bp}{Industrial}} 


This gives 'type in' boxes for the text areas and 'tick' boxes for the choices.

I'm not sure what happens about saving form data: according to Adobe Reader it can't be saved in this form. I've never actually seen a PDF form that can have the data saved, so whether even Acrobat can do this I do not know.

share|improve this answer
@Joseph Wright you need Acrobat professional to save the data, if I recall correctly, if you have it you can also enable the final copy of the pdf to be saved by those using the Reader alone. – Yiannis Lazarides Apr 3 '11 at 15:36
Or, if you use a Mac, Preview allows you to save the data. – Alan Munn Apr 3 '11 at 15:50
@Alan: I tried that, but it did not seem to work – Joseph Wright Apr 3 '11 at 15:50
@Joseph I haven't tried the eforms package itself, but I routinely generate a syllabus for a course I supervise using hyperref's pdf forms methods, and if you fill in the form and then Save As in Preview, it saves the filled in form. – Alan Munn Apr 3 '11 at 15:54
@Joseph: In case you're still interested in retrieving the membership form in .tex format, it is actually attached to the application form itself. Like a first goodie for new members :) – doncherry Apr 30 '11 at 11:41

Your Answer


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.