Como adicionar quebras de linha ao TextField do formulário PDF (hiperref)?

Como adicionar quebras de linha ao TextField do formulário PDF (hiperref)?

Considere o seguinte formulário de feedback sobre brinquedos:

\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}

Compilar isso com pdflatex fornece o seguinte aviso (duas vezes, um para cada \newline):

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

Isso não me surpreende, pois para a maioria dos campos PDF criados e preenchidos por meio de hiperref, não faz sentido ter quebras de linha e provavelmente não é suportado. No entanto, ao editar o formulário e salvar o arquivo resultante (usando o Okular no meu caso), eupodeadicione quebras de linha. Ao obter os dados do formulário usandoPyPDF2método PdfFileReader.getFields, eu recebo:

'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.'

Observe as novas linhas \n. Então parece ser possível. Gostaria de adicionar essas novas linhas ao meu arquivo LaTeX. Isso é possível? Como posso fazer isso?

Ingenuamente tentei adicionar literal \nas \textbackslash{n}, mas falhou:

'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.'

Responder1

Atualizar: na verdade é melhor usar \textCRou \textLF. Eles também funcionarão se a codificação for alterada.

\string\nfunciona para mim:

\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}

insira a descrição da imagem aqui

informação relacionada