Как добавить переносы строк в текстовое поле формы pdf (hyperref)?

Как добавить переносы строк в текстовое поле формы pdf (hyperref)?

Рассмотрим следующую форму отзыва об игрушке:

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

Компиляция с помощью pdflatex выдает следующее предупреждение (дважды, по одному для каждого \newline):

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

Это не удивляет меня в том смысле, что для большинства полей pdf, созданных и заполненных через hyperref, нет смысла иметь переносы строк и, вероятно, не поддерживается. Однако, отредактировав форму и сохранив полученный файл (используя Okular в моем случае), яможетдобавить переносы строк. При извлечении данных из формы с помощьюPyPDF2Методом PdfFileReader.getFieldsя получаю:

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

Обратите внимание на новые строки \n. Так что это кажется возможным. Я хотел бы добавить эти новые строки в свой файл LaTeX. Возможно ли это? Как мне это сделать?

Я наивно попытался добавить литерал \nкак \textbackslash{n}, но это не удалось:

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

решение1

Обновлять: на самом деле лучше использовать \textCRили \textLF. Они также будут работать, если изменится кодировка.

\string\nработает для меня:

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

введите описание изображения здесь

Связанный контент