2

I am using hyperref to render a form. I would like to initially fill the text fields with some dynamic content. Therefore, I have to escape special characters in the content. I managed to discover how I can escape &, %, $, #, _, and ^ by trial and error but how can I escape \, {, }, and ~?

\documentclass{article}

\usepackage{hyperref}

\begin{document}

\TextField[value={&\%$\#_^}]{}

% \TextField[value={\{}~}]{}

\end{document}
1
  • For the ~, \TextField[value={\~{}}]{} seems to work, as well as \textasciitilde. The Comprehensive LaTeX symbol list, p.10, recommends to use \textbackslash, \textbraceleft, \{ and \} for the other symbols you are looking for, but that does not seem to work. – Clément Jun 26 '14 at 15:15
2

I found a solution using the macro \pdfstringdef. Output of example code

\documentclass{article}

\usepackage{hyperref}

\begin{document}

\begin{Form}

\TextField[value={&\%$\#_^}]{}
\pdfstringdef{\foo}{\textbackslash\{\}\~{}}
\TextField[value={\foo}]{}

\end{Form}

\end{document}

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.