6

The following code can be compiled with pdflatex but not xelatex.

\documentclass{article}
\usepackage{graphicx,multido}
\begin{document}
\pdfximage{something.pdf}
\multido{\i=1+1}{\the\pdflastximagepages}{%
    \fbox{\includegraphics[page=\i,scale=0.25]{something}}
    \endgraf
}
\end{document}

The idea is to include each page of something.pdf as a separate image. I don't want to use pdfpages package and I want to use xelatex.

Are there macros that behave like \pdfximage and \pdflastximagepages but can be compiled with XeLaTeX?

1 Answers1

7

You can use

\edef\numberofpages{\the\XeTeXpdfpagecount something.pdf }

and then \numberofpages will expand to the number of pages of the file.

You can also use the same syntax as with pdfTeX by

\usepackage{ifxetex}

\ifxetex
  \newcount\pdflastximagepages
  \def\pdfximage#1{\pdflastximagepages=\XeTeXpdfpagecount"#1"\relax}
\fi

but of course you won't have the complete functionality of \pdfximage with XeTeX.

egreg
  • 1,121,712