How to make Table of Contents for a set of PDF files?

Here's my code!

\documentclass{book}
\usepackage{pdfpages}
\usepackage[pdfauthor={<somename>},pdftitle={<sometitle>},pdftex]{hyperref}
\usepackage{fancyhdr}
\usepackage{tocloft}
\usepackage[margin=0.5in,bottom=0.75in,top=0.75in]{geometry}

\pagestyle{fancy}
\begin{document}

\tableofcontents
\newpage

\clearpage
\phantomsection
\includepdfset{pages=-,pagecommand=\thispagestyle{fancy}}
\addcontentsline{toc}{chapter}{SAMPLE PDF 1\\ \textit{description}}
\includepdf[pages=-]{template1.pdf}

\clearpage
\phantomsection
\addcontentsline{toc}{chapter}{SAMPLE PDF 2\\ \textit{description}}
\includepdf[pages=-]{template2.pdf}

\clearpage
\phantomsection
\addcontentsline{toc}{chapter}{SAMPLE PDF 3\\ \textit{description}}
\includepdf[pages=-]{template3.pdf}

\clearpage
\phantomsection
\addcontentsline{toc}{chapter}{SAMPLE PDF 4\\ \textit{description}}
\includepdf[pages=-]{template4.pdf}

\clearpage
\phantomsection
\addcontentsline{toc}{chapter}{SAMPLE PDF 5\\ \textit{description}}
\includepdf[pages=-]{template5.pdf}

\end{document}


Here's the output.

My problem is that the page number is not aligned with the title, it is aligned with the description. Also I'd like to put dots.

My desired output looks like this:

-
Please don't use an external reference for your question. Linking to it is ok if you really want to, but try to make the question self-contained, so that answerers don't need to work simply to understand the question. –  T. Verron May 3 '13 at 6:31

This is adapted from some code I wrote once for a similar purpose. You simply call the macro \insertmydocument instead of \includepdf.

For the description, it turns out tocloft can handle the typesetting of a "chapter precis" in toc, in text or both. It seems to be exactly what you are looking for.

%The default settings should add dots, but for whatever reason it doesn't. This fixes it.

\newcommand{\insertmydocument}[4]%
{ % Syntax: \insertmydocument{Toc level}{Title}{Subtitle}{File}
% Requires: tocloft hyperref pdfpages
\newpage
\phantomsection
\cftchapterprecistoc{#3}
\includepdf[pages=-]{#4}
}


I suggest you add colorlink to the hyperref options, so that the links are colored instead of boxed. This will get rid of the big box on the first line.

## Full example

\documentclass{report}

\usepackage{pdfpages}

\usepackage{tocloft}

\newcommand{\insertmydocument}[4]%
{ % Syntax: \insertmydocument{Toc level}{Title}{Subtitle}{File}
% Requires: tocloft hyperref pdfpages
\newpage
\phantomsection
\cftchapterprecistoc{#3}
\includepdf[pages=-]{#4}
}

\begin{document}

\tableofcontents

\chapter{A regular chapter}

\insertmydocument{chapter}{A pdf}{Description}{document.pdf}

\chapter{Another chapter}

\end{document}


-
@ScareCrow : I hadn't understood the layout you were after. I edited my answer. –  T. Verron May 3 '13 at 9:51
@ T.Verron i want a layout like this: i.imgur.com/7tmSrId.png?1. im a newbie i want to try your code but i dont know where to put your codes in my codes. can you give me an example of a whole code? –  Scare Crow May 4 '13 at 3:37
@ScareCrow: Added the full code for the picture, you might need to change the name of the inserted pdf of course. –  T. Verron May 4 '13 at 5:15

for each PDF you can use the option addtotoc from pdfpages:

\includepdf[addtotoc={1,chapter,0,SAMPLE PDF 1,chap:samplepdfone}]{template1.pdf}

-