Is there a possibility to get the total number of pages of an external PDF file within a LaTeX document?
Assuming that there exists a PDF file test.pdf
with 8 pages in the same directory my LaTeX file is saved in. Here's my very basic approach:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{xparse}
\DeclareDocumentCommand \pdfnumberofpages { m } {
% Do some magic
}
\begin{document}
\texttt{test.pdf}: \pdfnumberofpages{test.pdf} pages
\end{document}
The resulting document should then contain
test.pdf: 8 pages
I know it should be possible somehow (pdfpages
must do something like this), but I don't know how to implement it.
Best Answer
After
\tracingmacros1
with optionpages=last-1
, it seems likepdfpages
uses a feature ofpdf(la)tex
to get the number.