I provide here a MWE:
\documentclass{article}
\usepackage{titletoc}
\usepackage[colorlinks=true
,urlcolor=blue
,anchorcolor=blue
,citecolor=blue
,filecolor=blue
,linkcolor=blue
,menucolor=blue
,linktocpage=true
,bookmarks=true
,unicode=true
,pdfa=true
]{hyperref}
\titlecontents{section}%
[9mm]
{}
{\contentslabel[%
\hyperlink{%
section.\thecontentslabel
}{%
\thecontentslabel.%
}]%
{7mm}}
{\hspace*{-7mm}}
{\hfill\contentspage}
{}
\titlecontents{subsection}%
[20mm]
{}
{\contentslabel[
\hyperlink{%
subsection.\thecontentslabel%
}{%
\thecontentslabel%
}]%
{12mm}}%
{\hspace*{-12mm}}
{\hfill\contentspage}
{}
\begin{document}
\tableofcontents
\section{First}
\subsection{FF}
\subsection{FS}
\section{Second}
\subsection{SF}
\subsection{FF}
\appendix
\section{App1}
\subsection{App1F}
\subsection{App1S}
\end{document}
I have to say that the toc is exactly as I want, but there is a strange issue: while all the "1." "2." and all the subsection name are clickable and led to the correct position "A." doesn't work. How can I fix this problem possibly without any other package?
EDIT
I thought my example was minimal but after I plug it in my case it didn't work properly: I post a MWE
\documentclass{article}
\usepackage{titletoc}
\usepackage[
colorlinks=true,
urlcolor=blue,
anchorcolor=blue,
citecolor=blue,
filecolor=blue,
linkcolor=blue,
menucolor=blue,
linktocpage=true,
bookmarks=true,
unicode=true,
pdfa=true,
]{hyperref}
\def\maposectionname{section}
\makeatletter
\g@addto@macro{\appendix}{%
\titlecontents{section}%
[2mm]
{}
{Appendix~%
\hyperlink{%
section.\thecontentslabel
}{%
\thecontentslabel.~%
}%
}%
{\hspace*{0mm}}%
{\hfill\contentspage}
{}
\addtocontents{toc}{\def\protect\maposectionname{appendix}}%
}
\makeatother
\titlecontents{section}%
[9mm]
{}
{\contentslabel[%
\hyperlink{%
\maposectionname.\thecontentslabel
}{%
\thecontentslabel.%
}]%
{7mm}}
{\hspace*{-7mm}}
{\hfill\contentspage}
{}
\titlecontents{subsection}%
[20mm]
{}
{\contentslabel[
\hyperlink{%
subsection.\thecontentslabel%
}{%
\thecontentslabel%
}]%
{12mm}}%
{\hspace*{-12mm}}
{\hfill\contentspage}
{}
\begin{document}
\tableofcontents
%\clearpage
\section{First}
\subsection{FF}
\subsection{FS}
%\clearpage
\section{Second}
\subsection{SF}
\subsection{FF}
%\clearpage
\appendix
\section{App1}
\subsection{App1F}
\subsection{App1S}
\end{document}