# [XeTeX] pdfpages and XeTeX

Jonathan Kew jonathan_kew at sil.org
Thu Sep 7 23:45:58 CEST 2006

On 7 Sep 2006, at 9:01 pm, Pablo Rodríguez wrote:

> I have to insert a 20-page PDF document into a XeTeX document (both
> use
> the same paper size). I have tried to use pdfpages, but I guess they
> don't fit together (it seems to have problems with the driver and it
> doesn't find the \includepdf command).

It would probably be possible to adapt pdfpages to work with xetex,
similarly to how the xetex.def file provides support for graphics,
but I haven't looked at it in detail.

> I guess xdvipdfmx can handle PDF documents (since dvipdfm does it). Is
> there any way to embed PDF documents with multiple pages in XeTeX?

The \XeTeXpdffile primitive accepts an optional "page" keyword to
select a page from the given file.

In XeLaTeX, \includegraphics will handle PDFs, which it delegates to
\XeTeXpdffile; by default this will include the first page of the
specified file, but you can select any page using the [page=...]
option. Thus,

\includegraphics[page=1]{mydoc.pdf}
\includegraphics[page=2]{mydoc.pdf}
\includegraphics[page=3]{mydoc.pdf}
\includegraphics[page=4]{mydoc.pdf}

would include 4 successive pages from the given file. But if you're
wanting to include complete pages, with the same size as the
containing document, then you'd have to do some extra macro work to
place them properly, as they won't fit if simply placed like normal
pictures.

A xetex driver for pdfpages, using \XeTeXpdffile, would be a good
project for someone to tackle....

JK