# Hyperref package (token not allowed in a PDF string)

When I start the appendix of the document always gives the problem of hyperref with \uppercase and it always appears:

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


How to solve?

\begin{apendicesenv}
% Imprime uma página indicando o início dos apêndices% Imprime uma página indicando o início dos apêndices
\partapendices
% ----------------------------------------------------------
\chapter{Questinários}
% ----------------------------------------------------------
\centering
\includegraphics[trim = 1.9cm 5cm 1.1cm 11mm,clip,width= 16cm]{Selecao.pdf}
% ----------------------------------------------------------
\chapter{Diagnóstico Inicial}
% ----------------------------------------------------------
\centering
\includegraphics[trim = 1.3cm 2cm 1.1cm 8mm,clip,width= 16cm]{diag.pdf}
\includepdf[pages={2-3},trim = 1.3cm 2cm 1.0cm 8mm,clip,width= 16cm]{diag.pdf}
\end{apendicesenv}

• Welcome to TeX.se. Please don't post a code fragment, but include a minimal, compilable document that shows the problem. The document must begin with \documentclasss{...} and end with \end{document}. Remove any packages or code that are unrelated. This is especially important in your case, since it appears that you are using a non-standard document class. – Alan Munn Feb 24 '18 at 21:31

\uppercase is a non-expandable command. Therefore, it must be called/executed to do its job, in TeX speech, the place is the stomach. Bookmarks, however, are generated in an expandable context, TeX's mouth. It is similar to writing to a file or to the console. Try:

\typeout{\uppercase{hello}}


As result \uppercase appears in the output and hello remains lowercase:

\uppercase {hello}


The code in hyperref that generates the bookmarks tries hard to avoid that such commands appear in the output and have successfully removed it, see the text of the warning. Of course, the text is not converted to uppercase, thus, the warning is justified.

There are two means to solve the situation without warning:

• \pdfstringdefDisableCommands can be used to remove unsupported commands:

\usepackage[...]{hyperref}
\pdfstringdefDisableCommands{\let\uppercase\@firstofone}

• \texorpdfstring can be used to replace unsupported constructs with replacement texts, e.g.:

\section{\texorpdfstring{\uppercase{hello}}{HELLO}}
`