1

Consider the following toy feedback form:

\documentclass{article}
\usepackage{hyperref}
  \renewcommand*{\DefaultHeightofTextMultiline}{20\baselineskip}

\begin{document}
  \centering
  \begin{Form}
    \TextField[multiline,width=\textwidth,
    value={%
      You should write your feedback in a readable way, for example using bullet points:
      * Insert at least 1 positive comment (mandatory)
      * Insert at least 1 critical comment or question (mandatory)
      \newline
      Use multiple paragraphs.
      \newline
      Some examples of concrete, actionable feedback:
      * The first figure does not have a caption; please add it.
      * The derivation of Equation (7) became unclear around Equation (5). I think this is because you did not make the substitution of x explicit and feel doing so would make the argument clearer.%
  },
  name=mytextfield]{}%
  \end{Form}
\end{document}

Compiling this with pdflatex gives the following warning (twice, one for each \newline):

Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding):
(hyperref)                removing `\newline' on input line 20.

This does not surprise me in the sense that for most pdf fields created and populated through hyperref, it does not make sense to have linebreaks and is probably not supported. However, by editing the form and saving the resulting file (using Okular in my case), I can add line breaks. When getting the data out of the form using PyPDF2's PdfFileReader.getFields method, I get:

'You should write your feedback in a readable way, for example using bullet points:\n* Insert at least 1 positive comment (mandatory)\n* Insert at least 1 critical comment or question (mandatory)\n\nUse multiple paragraphs.\n\nSome examples of concrete, actionable feedback:\n* The first figure does not have a caption; please add it.\n* The derivation of Equation (7) became unclear around Equation (5). I think this is because you did not make the substitution of x explicit and feel doing so would make the argument clearer.'

Notice the newlines \n. So it seems to be possible. I would like to add those newlines in my LaTeX file. Is this possible? How can I do this?

I naively tried to add literal \n as \textbackslash{n}, but that fails:

'You should write your feedback in a readable way, for example using bullet points:\\n * Insert at least 1 positive comment (mandatory)\\n * Insert at least 1 critical comment or question (mandatory)\\n \\n Use multiple paragraphs.\\n \\n Some examples of concrete, actionable feedback:\\n * The first figure does not have a caption; please add it.\\n * The derivation of Equation (7) became unclear around Equation (5). I think this is because you did not make the substitution of x explicit and feel doing so would make the argument clearer.'
3

\string\n works for me:

\documentclass{article}
\usepackage{hyperref}
  \renewcommand*{\DefaultHeightofTextMultiline}{20\baselineskip}

\begin{document}
  \centering
  \begin{Form}
    \TextField[multiline,width=\textwidth,
    value={%
      You should write your feedback in a readable way, for example using bullet points:\string\n
      * Insert at least 1 positive comment (mandatory)\string\n
      * Insert at least 1 critical comment or question (mandatory)\string\n
      Use multiple paragraphs.
      \string\n
      Some examples of concrete, actionable feedback:\string\n
      * The first figure does not have a caption; please add it.\string\n
      * The derivation of Equation (7) became unclear around Equation (5). I think this is because you did not make the substitution of x explicit and feel doing so would make the argument clearer.\string\n%
  },
  name=mytextfield]{}%
  \end{Form}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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