How can I crop included PDF documents?
You can crop/trim a pdf when including it using the trim=left botm right top
.
Full example:
\begin{figure}[htbp]
\centering
\includegraphics[clip, trim=0.5cm 11cm 0.5cm 11cm, width=1.00\textwidth]{gfx/BI-yourfile.pdf}
\caption{Title}
\label{fig:somthing}
\end{figure}
Note: Figuring out how far to trim can take time. To speed things up a bit it helps to draw a box around the image:
\fbox{\includegraphics[trim=0.5cm 11cm 0.5cm 11cm]{gfx/BI-yourfile.pdf}}
run pdfcrop
on the whole document, then every page is cropped and you can input it as usual with pdfpages
or alternatively with \inlcudegraphics[page=...]{<image>}
. I always use the pdfcrop
from Heiko Oberdiek which is already part of every TeX distribution. And, of course, Windows user need an installed Perl, eg http://www.activestate.com/perl
If the coordinates of the valuable parts in your PDF images is fixed, then the following method can be automated.
Use the following template to trim or crop images and compile it with xelatex
. You will get 2 pages, one for navigation and the other one is the cropped image.
% cropping.tex
\documentclass{article}
\usepackage{pstricks}
\usepackage{graphicx}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{pspicture}
% Set the border to 0pt if you don't like paddings.
\PreviewBorder=1cm\relax
% If you need 4 colored paddings, uncomment the following.
% But remmember that \PreviewBorder=0 will ignore it.
%\pagecolor{yellow!10}
\newsavebox\IBox
\savebox\IBox{\includegraphics[width=\linewidth]{leibniz.jpg}}
\def\N{15}% columns
\def\M{15}% rows
\psset
{
xunit=\dimexpr\wd\IBox/\N\relax,
yunit=\dimexpr\ht\IBox/\M\relax
}
\begin{document}
% First page for navigation
\begin{pspicture}(\N,\M)
\rput[bl](0,0){\usebox\IBox}
\psgrid[style=gridstyle]
\end{pspicture}
% Second page for the final output
% Cropping coordinates
\def\Left{6}
\def\Bottom{8}
\def\Right{10}
\def\Top{13}
\begin{pspicture}(\Left,\Bottom)(\Right,\Top)
\begin{psclip}{\psframe[linestyle=none](\Left,\Bottom)(\Right,\Top)}
\rput[bl](0,0){\usebox\IBox}
\end{psclip}
\end{pspicture}
\end{document}
From within your main TeX document, you can import the second page of cropping.pdf
simply by using \includegraphics[page=2,scale=<number>]{cropping.pdf}
.
Please read the comments in the source file to modify the padding thickness or padding color.
Note: This example uses Gottfried Leibniz's picture.