# Find the page size in a PDF file using LaTeX

I sometimes use LaTeX in conjunction with pdfpages package to manipulate the pages of a PDF file (not necessarily created by LaTeX), operations like combining several pages into one, or changing the order of pages.

The question I have is how to find the size of each page in an external PDF file? I want to use pdfpages to reorder the pages by height.

There are probably much easier ways to do this, but you could use \settoheight to measure the height of a page:

\documentclass{article}

\newlength{\imageheight}

\usepackage{graphicx}

\usepackage{printlen} % only for demonstration

\begin{document}

\settoheight{\imageheight}{\includegraphics[page=1]{example-image-a4}}

\uselengthunit{cm}\printlength{\imageheight} % only for demonstration
\end{document}