I have a multipage PDF manuscript (for example, my_PDF.pdf
) that I would like to include in a new document. I would also like to trim/clip off the header and footer from each page of this included pdf.
In the past, with regular LaTeX, I have done this very simply with something like
\documentclass[letterpaper]{article}
\usepackage{pdfpages}
\begin{document}
\includepdf[pages={1,2},trim=0.45in 0.625in 0.45in 0.625in, offset=0.25in 0in, width=6in, clip=true, pagecommand={}]{my_PDF}
\end{document}
as described at http://en.wikibooks.org/wiki/LaTeX/Importing_Graphics.
However, this time I need to do it in XeTeX for Unicode support, and the above method doesn't work because clipping isn't supported yet in XeTeX. I've managed to come very close by using the nice adjustbox
package, which lets you (almost) transparently redefine the \includegraphics
macro in a way that supports clipping:
%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode
\setlength{\pdfpagewidth}{8.5in} % Something wrong with my compiler setup
\setlength{\pdfpageheight}{11in}
\documentclass[letterpaper]{article}
\usepackage{pdfpages}
\usepackage[Export]{adjustbox}
\begin{document}
\includepdf[pages={1,2},trim=0.45in 0.625in 0.45in 0.625in, offset=0.25in 0in, width=6in, clip=true, pagecommand={}]{my_PDF}
\end{document}
But now I'm stuck again because it doesn't seem the \adjustbox
way can select different pages in the multipage PDF (i.e. this second code example repeatedly inserts the same properly-trimmed first page).
Is there a way to make this work? Maybe I'm missing a way to select the pages? Or somehow use the original way to insert the pages, in combination with some sort of pagecommand={\adjustbox{...}}
key to the \includepdf
macro? (I tried this too, but I am a relative novice and couldn't get it going) Perhaps there's a totally different method that I'm missing. Basically, I just want to be able to insert a cropped/trimmed multipage PDF document inside an XeTeX document.
Best Answer
[Summary of comments as a community wiki answer.]
One option would be to generate a cropped PDF using pdfLaTeX and the
pdfpages
package, and then to use this PDF in a XeLaTeX run. You might also consider LuaLaTeX in place of XeLaTeX, depending on your exact requirements. Clipping for XeLaTeX is now sorted out foradjustbox
, so you may wish to revisit this approach.