# Is there a way to \label each page in an included pdf file?

I am including a PDF file as part of my reports appendices.

The PDF file does not have page numbers, these are added using pagecommand=\thispagestyle{plain} which continues the LaTeX page numbering.

\usepackage{pdfpages}
\includepdf[pages=-, pagecommand=\thispagestyle{plain}]{file.pdf}


How would I make it possible to refer to each PDF page using \pageref{} in the rest of my report?

Here's a quick hack:

\documentclass{article}
\usepackage{pdfpages}

\newcounter{pdfpage}

\begin{document}

The second page of the included PDF file is on page~\pageref{file-2}.

\setcounter{pdfpage}{0}
\includepdf[pages=-,pagecommand={\thispagestyle{plain}\refstepcounter{pdfpage}\label{file-\thepdfpage}}]{file.pdf}

\end{document}


The custom counter pdfpage needs to be reset with every new includepdf.