2

I want to have \q{} many lines, while it is designed for one line now. For example, take value from 2 to the maximum amount of lines per frame. Code based on Christian's thread answer Creating fillable PDFs.

% https://tex.stackexchange.com/a/14845/13173
\documentclass{beamer}
\usetheme{Berkeley}

%https://tex.stackexchange.com/a/14845/13173
    \usepackage[latin1]{inputenc} 

    \newdimen\longline
    \longline=\textwidth\advance\longline-4cm

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

    \def\lbl#1{\hbox to 4cm{#1\dotfill\strut}}%
    \def\labelline#1#2{\lbl{#1}\vbox{\hbox{\TextField[name=#1,width=#2,bordercolor=white]{\null}}\kern2pt\hrule}} % https://tex.stackexchange.com/a/374712/13173

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

\begin{document}

\section{Lorem}
\begin{frame}
  \begin{Form}
    \q{Merkki:} % TODO have here many lines
%   \q{}
%   \q{}
  \end{Form}
\end{frame}

\end{document}

Output in Fig. 1

Fig. 1 Output with only one line

enter image description here

Expected output: to have many lines (etc 3) for the input, and show the input on another page

Testing UlrikeFisher's proposal in one environment

Code

\documentclass{beamer}
\usepackage[english]{babel}
\usetheme{Berkeley}

%\usepackage[margin=1pt]{geometry}% http://ctan.org/pkg/geometry % Beamer loads geometry already!

% https://tex.stackexchange.com/a/387474/13173
\usepackage{xparse,calc}
\usepackage{eforms}

\begin{document}

\begin{frame}{Henkil\"{o}tiedot}
 % #Henkilotiedot https://tex.stackexchange.com/a/387474/13173
 \medskip
 \textField[
    \Ff\FfMultiline
    \Ff\FfDoNotSpellCheck
           ]
  {myinput}{\dimexpr\linewidth-10ex}{5\baselineskip}
\end{frame}

% https://tex.stackexchange.com/a/385265/13173
\pdfpagewidth 21cm
\pdfpageheight 29.7cm

%% #Henkilotiedot
 \textField[
    \Ff\FfMultiline
    \Ff\FfDoNotSpellCheck
    \Ff\FfReadOnly
    \AA{\AACalculate{event.value=getField("myinput").value;}}
           ]
  {myoutput}{\dimexpr\linewidth-10ex}{5\baselineskip}

% https://tex.stackexchange.com/q/385438/13173
\newcommand*{\TableA}{%
%  \textcolor{gray}{\rule{.5\linewidth}{10cm}}%
    \begin{table}[hpt]
        \setlength\tabcolsep{1pt} % default value: 6pt % https://tex.stackexchange.com/a/201117/13173

        \begin{tabular}{|p{.2cm}|l|l|l|l|l|l|l|p{.2cm}|}
        \hline
        \rot{{\tiny\textbf{Avain muuttuja}}} 
        & \textbf{V2} & \textbf{V1} & \textbf{V0} 
            & \textbf{TESTI Muuttujat} 
            & \textbf{P1} & \textbf{P2} & \textbf{P3} 
            & \rot{{\tiny\textbf{Kriittinen muuttuja}}} \\ \hline
         &  &  &  & 1. Sosiaaliset taidot &  &  & & \\ \hline
         &  &  &  & 2. Ihmissuhteet (TS: K/E)* &  &  & & \\ \hline
         &  &  &  & 3. Ammatillinen arvio &  &  & & \\ \hline
        \end{tabular}
    \end{table}
}
\newcommand*{\TableB}{%
  \textcolor{red}{\rule{.5\linewidth}{3cm}}%
}
\newcommand*{\TableC}{%
  \textcolor{green}{\rule{.5\linewidth}{3cm}}%
}
\newcommand*{\TableD}{%
  \textcolor{blue}{\rule{.5\linewidth}{3cm}}%
}


% Show summary here from Page 1 and 2
\begingroup
\setbeamertemplate{navigation symbols}{}%remove navigation symbols
\section{Summary}
\begin{frame}[plain]
    \vskip 1.5cm
    \hspace*{-1.7cm}% to leave 1.0 cm margin
\begin{minipage}{19cm}
    \begin{center}
    TESTI
    \end{center}


    % Pisteytyskohta https://tex.stackexchange.com/q/385438/13173
    \begin{adjustbox}{max width=\textwidth}
        \sbox0{\TableA}%
        \noindent
        \vtop{%
          \kern0pt % Align at the top
          \copy0 %
        }%
        \kern-.2pt %
        \vrule
        \kern-.2pt %
        \vtop to \dimexpr\ht0+\dp0{%
          \kern0pt % Align at the top
          \hbox{\TableB}%
          \vfill
          \hbox{\TableC}%
          \vfill
          \hbox{\TableD}%
        }
    \end{adjustbox}

\end{minipage}
\end{frame}

% these below eventually are not needed, if this is the last slide of your document
\makeatletter
\pdfpagewidth \beamer@paperwidth
\pdfpageheight \beamer@paperheight
\makeatother
\endgroup

\end{document}

Fig. 2 Page setting is affected by the environment

enter image description here

OS: Debian 9
TeXLive: 2017
Acrotex installation: here

3
  • In trying to answer this, I realise it isn't really clear what you want, even though I initially thought it was :(.
    – cfr
    Commented Aug 20, 2017 at 3:00
  • 1
    I've edited my answer below for a case in which the form fields are multi-line. The single-line case works as desired, I'm told. I assume the multi-line case will also, but it is currently awaiting testing. (None of this works in Okular and I don't have access to Adobe Reader to test myself right now.)
    – cfr
    Commented Aug 20, 2017 at 20:26
  • I guess there's a question about where you need it to work. I need forms I can produce on Linux, but I only need them to work on Windows, so stuff which works OK in Adobe Reader is fine. But the forms stuff is not supported properly by any PDF viewer I'm familiar with for Linux. (If you know one which does support it properly, please let me know!)
    – cfr
    Commented Aug 20, 2017 at 20:28

2 Answers 2

4
+50

It is a bit unclear what you mean with many lines. But in case that you want a multiline text field, here an example with eforms. To get the value to the output page you can either use the same field name (but then you can't give them different "readonly" values), or use javascript (this needs a pdf viewer that can handle it):

\documentclass{beamer}
\usetheme{Berkeley}
\usepackage[utf8]{inputenc}
\usepackage{xparse,calc}
\usepackage{eforms}
\begin{document}
\begin{Form}
\begin{frame}{Input}
 Question:  Say something about ....

 \medskip

 \textField[
    \Ff\FfMultiline
    \Ff\FfDoNotSpellCheck
           ]
  {myinput}{\dimexpr\linewidth-10ex}{5\baselineskip}

\end{frame}
\begin{frame}{Output}


 \textField[
    \Ff\FfMultiline
    \Ff\FfDoNotSpellCheck
    \Ff\FfReadOnly
    \AA{\AACalculate{event.value=getField("myinput").value;}}
           ]
  {myoutput}{\dimexpr\linewidth-10ex}{5\baselineskip}

\end{frame}
\end{Form}
\end{document}

enter image description here

enter image description here

4
  • Create a small testtexmfhome.tex with some HELLO WORLD in it. Move is to a new folder in insert-your-texmfhome-here/tex/latex/myfiles (get texmfhome with kpsewhich -var-value=TEXMFHOME) . Test in a document with \input{testtexmfhome} if is it found. If it works copy the files for acrotex there too. Commented Aug 27, 2017 at 7:36
  • I am trying to integrate your proposal in the environment with unique page setting unsuccessfully. Can you please see the body? How can you encapsulate the new textfield better? Commented Oct 5, 2017 at 8:50
  • 2
    I have no idea what you are actually trying to achieve. Why are you changing the page size? And why this complicated code for the tabulars? Commented Oct 5, 2017 at 17:52
  • Yes, I am changing the pagesize there. The complicated code with tabularx is for the presentation target there only. The aim is carry the text field info to the last presentation page of different page format. Commented Oct 5, 2017 at 18:17
3

I cannot test this without Adobe Reader (or another compliant PDF viewer). However, this should work based on the usual behaviour. Moreover, comments say this does work as expected, even with the command wrapper used here.

Basically, if you give two text fields the same name, then filling in one populates both. I know this because I never want this behaviour and I have sometimes caused it accidentally, only to discover in class than I cannot fill out two different text fields with different content. (When I get to the second slide with a field of the same name, the field is pre-populated with an earlier answer. I can delete it and write a new answer, but that erases what I've input on the earlier slide.)

However, Okular does not appear to respect this behaviour, so I can't check that wrapping this in a macro works correctly. (Adobe crashes on Linux before you have time to blink. Well, first it takes a few hours to start. Then it freezes. Then it crashes before you have time to blink. Generally. It is not as predictable as one might like.)

Here's my original answer for the multiple single-line fields case. (See below for a multiple multi-line fields case.)

\documentclass{beamer}
\usetheme{Berkeley}
\usepackage[utf8]{inputenc}
\usepackage{xparse,calc}
\makeatletter
\newlength\textinput@labelwd
\newlength\textinput@fieldwd
\newlength\textinput@ht
\setlength\textinput@labelwd{40mm}
\setlength\textinput@fieldwd{\textwidth-40mm}
\setlength\textinput@ht{12pt}
\def\LayoutTextField#1#2{%
  \makebox[\textinput@labelwd]{\strut #1: \dotfill{} }#2%
}
\NewDocumentCommand\textinput{ s o +m }{%
  \IfValueTF{#2}{\edef\textinput@tempa{#2}}{\edef\textinput@tempa{#3}}%
  \IfBooleanTF{#1}{\edef\textinput@tempb{true}}{\def\textinput@tempb{false}}%
  \TextField[charsize={10pt},multiline=false,height=\textinput@ht,width={\textinput@fieldwd},name={\textinput@tempa},bordercolor={1 1 1},readonly=\textinput@tempb]{#3}%
}
\makeatother
\begin{document}
\begin{Form}
  \begin{frame}{Input}
  \textinput{Merkki}

  \textinput[qna]{Qn.~A}

  \textinput[qnb]{Qn.~B}

  \textinput[merkki2]{Merkki}
\end{frame}
\begin{frame}{Output}
  \textinput{Merkki}

  \textinput[qna]{Qn.~A}

  \textinput[qnb]{Qn.~B}

  \textinput[merkki2]{Merkki}
\end{frame}
\end{Form}
\end{document}

Note that it probably matters that the frames occur in the same Form. However, I've never tried using Form inside a frame so I can't be sure of this. (I just always have \begin{document}\begin{Form} ... \end{Form}\end{document} in Beamer presentations.)

Here's an uninformative screenshot from Okular:

uninformative screenshot

EDIT

Here's a multiple multi-line fields case, which is apparently what's wanted here.

\documentclass{beamer}
\usetheme{Berkeley}
\usepackage[utf8]{inputenc}
\usepackage{xparse,calc,xcoffins}
\makeatletter
\newlength\textinput@labelwd
\newlength\textinput@fieldwd
\newlength\textinput@ht
\setlength\textinput@labelwd{40mm}
\setlength\textinput@fieldwd{\textwidth-40mm}
\setlength\textinput@ht{15mm}
\NewCoffin\textinputcoffin
\def\LayoutTextField#1#2{%
  \SetVerticalCoffin\textinputcoffin{\textinput@labelwd}{%
    \strut #1: \dotfill{} %
  }%
  \TypesetCoffin\textinputcoffin[t,l](0pt,\textinput@ht)#2%
}
\NewDocumentCommand\textinput{ s o +m }{%
  \IfValueTF{#2}{\edef\textinput@tempa{#2}}{\edef\textinput@tempa{#3}}%
  \IfBooleanTF{#1}{\edef\textinput@tempb{true}}{\def\textinput@tempb{false}}%
  \TextField[charsize={10pt},multiline=true,height=\textinput@ht,width={\textinput@fieldwd},name={\textinput@tempa},bordercolor={1 1 1},readonly=\textinput@tempb]{#3}%
}
\makeatother
\begin{document}
\begin{Form}
  \begin{frame}{Input}
  \textinput{Merkki}

  \textinput[qna]{Qn.~A}

  \textinput[qnb]{Qn.~B}

  \textinput[merkki2]{Merkki}
\end{frame}
\begin{frame}{Output}
  \textinput{Merkki}

  \textinput[qna]{Qn.~A}

  \textinput[qnb]{Qn.~B}

  \textinput[merkki2]{Merkki}
\end{frame}
\end{Form}
\end{document}

And an equally uninformative screenshot from Okular again:

another uninformative screenshot

Note that Okular does show the fields, but not in screenshots.

14
  • do you mean to test it on debian 9? And is there a reason to try on 2017 version? or my 2016 is ok to test it?
    – koleygr
    Commented Aug 20, 2017 at 3:17
  • 1
    @koleygr Thanks. So the readonly doesn't work even in Adobe's Reader. Interesting. Thanks very much for testing. (I don't know the readonly can work - I've never used it before. I only knew that naming the fields has this effect because I've done it by accident. It doesn't show on my machine in Okular, but then trouble when I use the slides in class on Windows.)
    – cfr
    Commented Aug 20, 2017 at 22:23
  • 1
    Why do you use the readonly? I'm not sure that I understand its purpose. Commented Aug 21, 2017 at 8:52
  • 1
    no this doesn't work. Such "twin"-fields share also most of their features (and normally the settings of the first field win). Commented Aug 21, 2017 at 12:54
  • 1
    @UlrikeFischer As I said, the testing above showed it doesn't work.
    – cfr
    Commented Aug 21, 2017 at 13:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .