I've got a PDF that is automatically generated from a certain piece of software, that I want to include in the report I'm writing. I'm using pdfpages which gets the job done elegantly, but the problem is, the PDF has a lot of white space around the actual content (which is a graphics) and I always have to do some tedious post-processing of the automatically generated document so that it fits well in my report. Changing the output of the software to eliminate the white space is not an option (or at least, would be much more trouble than it's worth).

I checked the pdfpages manual, but wasn't able to find an option that does that. Ideally, I'd like to be able to set margins from each direction, and the PDF is then cropped accordingly and included.

What other options do I have to control what portion of the included PDF is visible in the final document?


8 Answers 8


Run pdfcrop on the whole document, which will crop every page individually. I always use the pdfcrop from Heiko Oberdiek which is already part of every TeX distribution. You may also need to install perl.

You can then input the resulting PDF as usual with pdfpages or alternatively with \includegraphics[page=...]{<image>}.


You can crop/trim a pdf when including it using the trim=left botm right top.

Full example:

        \includegraphics[clip, trim=0.5cm 11cm 0.5cm 11cm, width=1.00\textwidth]{gfx/BI-yourfile.pdf}

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}}
  • 15
    I think you are missing the clip key, otherwise the trimmed content is still displayed. Ok, for the OP document that content is only whitespace, but other people might have something else, maybe a page number, which should be removed. Commented Jul 3, 2013 at 10:43
  • 21
    It should be noted that this way the complete original image (AFAIK for PDF just the selected page) is added to the output PDF and the clipping is done using added PDF instructions executed by the PDF viewer. For smaller clipping amounts that would be perfectly reasonable, but I wouldn't do it if I only want a small amount of a larger image in order to keep the output PDF small. It's also not recommended if the part which is clipped away contains sensitive informations, because the original image can be extracted using a suitable PDF tool. Commented Jul 3, 2013 at 10:43
  • 2
    Thanks Martin for pointing this out. In my use case I had an auto generated pdf with too much whitespace around it and didn't want manually crop it each time it was generated. So feel free to edit my post accordingly.
    – s.Daniel
    Commented Jul 4, 2013 at 12:02
  • When I add clip, trim=0.5cm 11cm 0.5cm 11cm, to my existing includegraphics call inside the brackets before my existing (and working) width= parameter, I get ! Undefined control sequence. \ETE@OrgGin@setfile ...\fi \fi \Gin@viewport@code \Gin@nat@height \Gin@ury b... Is there some special package that one needs in order to use trim?
    – sh37211
    Commented Apr 5, 2023 at 2:20

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


% Set the border to 0pt if you don't like paddings.

% If you need 4 colored paddings, uncomment the following.
% But  remmember that \PreviewBorder=0 will ignore it.


\def\N{15}% columns
\def\M{15}% rows


    % First page for navigation

    % Second page for the final output
    % Cropping coordinates

enter image description here

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.

  • Note: Clipping with PSTricks is more robust than \includegraphics[viewport=...,clip]{} when using xelatex. Commented Aug 16, 2011 at 10:00
  • How can this be automated to multipage pdfs? Commented Mar 24, 2020 at 15:08

You can do this with pdfpages. The following example takes a two-up scan of a book, and crops and collates it to a one-up document.


%% my pdf file has 132 pages:
%% my pdf file has size 780 x 610 points
\includepdf[pages=\thepg,viewport=0 0 390 610]{scan.pdf}
\includepdf[pages=\thepg,viewport=390 0 780 610]{scan.pdf}
  • 3
    This works, but any print outside the viewport is still printed unless you add the clip keyword. Commented Mar 8, 2015 at 0:49

Since you'd like to "...set margins from each direction, and the PDF is then cropped accordingly..." in order to "...control what portion of the included PDF is visible in the final document..." I would suggest you try Briss. It's easy to use and gives you much more control than pdfcrop.


You can do it inside your tex document using a boundig box:

 \includegraphics[bb = 0 10 612 7925,clip=true]{yourfile.pdf}

This means that the figure fits inside a rectangle with lower left corner at (0,10) and upper right corner (612,792). The unit is 1/72 inches (.3528 mm) measured from the lower left corner of the paper.


If you check now the pdfpages manual, you will read:

Internally the command \includepdf makes use of the \includegraphics command from the graphicx (actually graphics) package. Hence it is possible to use all the options of \includegraphics, too. Options which are not interpreted by \includepdf are passed directly to \includegraphics. Especially the trim and clip options of \includegraphics are quite useful (...).

So you can simply use \includepdf[trim=5cm 10cm 0 0, clip]{./YourSource.pdf}

  • 1
    This answer is underrated! I think this is the best and most straight forward answer someone can get for this problem.
    – agentsmith
    Commented Jan 31, 2022 at 12:06

On Mac OS-X you can use Skim or the built-in Preview to crop PDFs: Just open the PDF, select the crop area and choose Tools->Crop (⌘+K).

If you need to keep the original, just copy the selection (⌘+C) and choose File->New from Clipboard (⌘+N).

If you want to use one of the LaTeX-based methods, Skim might still be helpful to determine the bounding box coordinates (it prints them in the status bar when selecting an area).

  • For macOS Preview, you may need to enter select mode (Tools > Rectangular Selection) before Crop works.
    – Allison
    Commented Dec 15, 2022 at 6:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .