# Using fmtcount Commands in PDF Bookmarks/Index

Instead of having the arabic numerals, I want the number for each section in the text and in the bookmarks to be displayed as written-out text (thirty-four instead of 34). I'm trying to do this using the fmtcount package command \Numberstring. What I've got looks something like this for a counter chap:

\section*{\Numberstring{chap}}


\Numberstring works fine in the section text, but not in the bookmarks. pdflatex gives the following warning:

Package hyperref Warning: Token not allowed in a PDF string (Unicode):


I take this to mean that \Numberstring{chap} is giving the TOC a token rather than just text, and that there is a problem because PDF bookmarks must be only text. Is there any way to convert the token(?) that \Numberstring{chap} gives to text so that this will work? Is there some better way of going about this that I am not aware of?

To provide a MWE, my overall setup is that I have chapters of a book 1.tex, 2.tex, etc. in a directory and I have a \forloop to create a new section for each one, add a listing for each one into the TOC (for the PDF bookmarks), and input the file.

\documentclass{article}
\usepackage{forloop}
\usepackage{fmtcount}
\usepackage[bookmarks]{hyperref}

\begin{document}

\newcounter{chap}
\forloop{chap}{1}{\value{chap}<42}{
\section*{\Numberstring{chap}}
\input{chapter/\arabic{chap}.tex}
}

\end{document}


You can use \storeNumberstring that (apart from being badly implemented) allows to store the result of \Numberstring in a save place and to retrieve it.

\documentclass{article}
\usepackage{fmtcount}
\usepackage[bookmarks]{hyperref}

\newcommand{\mysection}{%
\stepcounter{chap}%
\section*{\Numberstring{chap}}%
\storeNumberstring{thisnumber}{chap}%