Text FormattingUnderline each line of a multiline form (using eforms)

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
rhino7890
Posts: 10
Joined: Fri Sep 24, 2010 7:27 pm

Underline each line of a multiline form (using eforms)

Post by rhino7890 »

I am using the eforms package to make an interactive form. I would like to have an interactive text field that looks something like this

text: ________________________________________
________________________________________
________________________________________
________________________________________

(i.e. a multiline text field with EACH line underlined). This way, if I want to use a hard copy of the form, there is still some definition to the text field. I have used the following command

text:

Code: Select all

\textField[\Ff{\FfMultiline}\S{U}]{ID}{width}{height}
but this results in the following

<Blank>
text: <Blank>
<Blank>
________________________________________


where only the last line of the text field is underlined.

Does anyone have any ideas on how I can get EACH line underlined? Someone from another forum (http://www.acrotex.net/forum/showthread.php?tid=86) suggested I use a background image with the appropriate lines and then place it behind the text field. This sounded good in theory, but I have not been able to figure out how to implement this idea. The following is code what I came up with to make the background image (which uses the package eso-pic):

Code: Select all

\usepackage{eso-pic}
\usepackage{forloop}
%->> usage: \BackgroundPic{<width>}{<number of lines>}
\newcommand\BackgroundPic[2]{
    \AddToShipoutPicture*{
        \put (0,0){
            \parbox[b][#2\baselineskip]{#1}{%
                \forloop{ct}{1}{\value{ct} < #2} { \noindent\_\hrulefill\\ }
            }
        }
    }
} 
The problem with this code is that the package eso-pic only lets you put the background image at an absolute location on the page (as defined by the command \put). I have therefore been having trouble placing this background image behind a text field box.

Any ideas?

Thanks!
Last edited by rhino7890 on Thu Oct 07, 2010 9:06 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

rhino7890
Posts: 10
Joined: Fri Sep 24, 2010 7:27 pm

Underline each line of a multiline form (using eforms)

Post by rhino7890 »

So I figured out a way to get this to work :D . It may not be the most elegant way, but it works.

I ended up making a background which contained all of the underlines that I wanted in the text field. I then overlay the text field using the \vspace command to shift my current location in the document back up to where I defined the underlines. I then placed a text field there, essentially overlaying it over the underlines.

Here is the code.

Code: Select all

\documentclass[12pt]{article}

\usepackage{forloop}
\usepackage[pdftex]{eforms} 

% Counter used in for loop
\newcounter{ct}	

% Specify the number of lines in the text field (you will get one less that this number)
\newcommand{\numLines}{6}

% Set the height of the text field base on the number of lines
\newlength\multilen
\setlength\multilen{\numLines\baselineskip}

\begin{document}

% Make a paragraph box
\parbox[t][\multilen]{\linewidth}{
   % Adjust the starting point of the text box 
   \vspace{0.25\baselineskip}    
   
   % Make a set up of underlines       
   \forloop{ct}{1}{\value{ct} < \numLines}{\noindent\_\hrulefill\\} 
   
   % Shift the text starting point up to beginning of paragraph (this takes some trial 
   % and error. These are the parameters that I found to work best.)
   \vspace{-\multilen}\vspace{-0.25\baselineskip}	
      
   % Make text box. The one thing that isn't perfect here is that the text in the text box 
   % doesn't always line up well with the lines. This also takes some trial and error
  \textField[\Ff\FfMultiline\W{1}\S{}\BC{}\textSize{11}]{Testing}{\linewidth}{\multilen}   
   \\
   }
\end{document}
If anyone comes up with a better way, let us know, but for now I'm going to mark this post solved.
Post Reply