# How to cut pdf at crop marks?

I have a PDF document, evidently produced using LaTeX, which has wide white margins and crop marks. I'd like to remove these margins and corresponding crop marks. Is there a tool to do it automatically?

EDIT Werner suggested to use pdfpages package to include PDF's pages in a LaTeX document. I should actually include only the pages of the PDF I'd like to crop and use options to trim it. I'm waiting for an help in recognizing the most appropriate options to do so.

• Do you want to cut the physical document along the crop marks (off-topic)? Or do you want to remove the crop marks and retain a crop-mark-free PDF? – Werner Jan 11 '16 at 17:54
• Try Master PDF 3, it's free if you use it with noncommercial purposes. It allows you to modify PDFs in pretty much any way, doing what you ask for should be a piece of cake. – Alfredo Hernández Jan 11 '16 at 18:22
• I believe pdfpages has a crop option. After all, it is based on \includegraphics. – John Kormylo Jan 11 '16 at 20:06
• @EnricoMariaDeAngelis: This is possible with pdfpages. – Werner Jan 12 '16 at 15:01
• But note with pdfpages all kinds of links will get lost. Have a look at jPDF Tweak (written in Java), by Michael Schierl. – Javier Bezos Jan 15 '16 at 15:18

The pdfcrop utility is made to crop the white borders from a PDF.

pdfcrop in.pdf out.pdf


If you want to remove a little MORE so that the crop marks are also removed, then use the --margins option. Providing a negative margin value will cause a crop of some of your content. The margin value unit is bp. Play with the negative value to remove your tick marks and nothing else.

pdfcrop --margins -10 in.pdf out.pdf


Edit Using OP's sample PDF follows...

Your sample PDF file works for me. I used the following command.

pdfcrop --margins -10 --verbose matC.pdf matC_cropped.pdf


This is your original file

And this is the cropped file

The pdfcrop verbose log follows

PDFCROP 1.38, 2012/11/02 - Copyright (c) 2002-2012 by Heiko Oberdiek.
* PDF header: %PDF-1.5
* Running ghostscript for BoundingBox calculation ...
GPL Ghostscript 9.04 (2011-08-05)
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 1.
Page 1
%%BoundingBox: 3 3 205 205
* Page 1: 3 3 205 205
%%HiResBoundingBox: 3.667289 3.061336 204.622728 204.016705
* Running pdfTeX ...
This is pdfTeX, Version 3.14159265-2.6-1.40.16 (MiKTeX 2.9 64-bit)
entering extended mode
(tmp-pdfcrop-3248.tex [1 <./matC.pdf>] )
Output written on tmp-pdfcrop-3248.pdf (1 page, 24335 bytes).
Transcript written on tmp-pdfcrop-3248.log.
==> 1 page written on matC_cropped.pdf'.


As you see, pdfcrop used ghostscript. Perhaps your ghostscript has an issue.

• This doesn't work for me. I mean the output file is exactly the same as the input one. – Enrico Maria De Angelis Jan 12 '16 at 9:03
• @EnricoMariaDeAngelis: pdfcrop will only detect white margins. Perhaps you have a background color or the pdf is a scan with random non-white dots in the background? Have you tried the command with the --margins option? That should work with or without a white background. Try increasing the --margins number to -100 and see if there is a noticeable change. If not, are there any error messages output by pdfcrop? – James Jan 12 '16 at 12:42
• No, it's not a scan, nor it has background color. I tried increasing the number to -100, but it didn't work. No errors, just output coincides with input. – Enrico Maria De Angelis Jan 12 '16 at 13:28
• @EnricoMariaDeAngelis: Maybe you could try the commands on another PDF to see if the tool is working in the general case. It's always worked for me. I don't know enough about pdfcrop to understand why else it might fail. If you want to provide a link to your PDF file I would be willing to try it on my computer. – James Jan 12 '16 at 13:39
• I cannot broadcast the material, but I can provide you a link to a pdf image (the outcome of an externalized tikzpicture) which has white margins that I can't eliminate by means of pdfcrop – Enrico Maria De Angelis Jan 12 '16 at 15:04

I finally solved the problem using the option fitpaper=true (manually setting the trim option).

\documentclass{article}
\usepackage{pdfpages}
\begin{document}
\includepdf[pages={2-32},trim=2.9cm 3.5cm 2.9cm 3.5cm,fitpaper=true]{Chapter05.pdf}
\end{document}


EDIT: If I think to non LaTeX solutions, briss comes up to my mind.

One option would be to iterate over all the pages in your document with crop marks, and each page is trimmed and clipped to remove the crop marks.

First step is to obtain the number of pages to include. For that, see Get number of pages of external PDF.

Second is we iterate over the number of pages sequentially (using multido). At each page, we create a new completely blank page in your document (using \newpage \thispagestyle{empty} \mbox{}) and insert a page from the PDF as an overlay using eso-pic). The overlay is placed in the ForeGround on that specific page only (due to *), with the appropriate horizontal and vertical shifts that we removed (trimmed from the original page image).

\documentclass{article}
\usepackage{multido,geometry,eso-pic,graphicx}
\usepackage{pdfpages}
\geometry{paper=a4paper}

\begin{document}

\includepdf{provacrop}% For reference

% https://tex.stackexchange.com/q/198091/5764
\pdfximage{provacrop.pdf}%
\edef\numberofpages{\the\pdflastximagepages}%

\multido{\i=1+1}{\numberofpages}{%
\newpage% Start a new page
\mbox{}% Just to put something on this blank page
\edef\x{%
\noexpand\AtPageLowerLeft{%
\noexpand\hspace{20mm}% Horizontal shift
\noexpand\raisebox{25mm}{% Vertical shift
\noexpand\includegraphics[trim=20mm 25mm 20mm 25mm,clip,page=\i]{provacrop}}%
}%
}}\x%
}

\end{document}


Above I've trimmed 20mm horizontally and 25mm vertically just to show how it affects the output. You could play around with these lengths until the crop marks disappear.

The use of \edef\x{..}\x is to ensure the proper choice for page=\i - \i has to be completely expanded in order to be processed correctly by \includegraphics`.

• Copied the code, I get exactly what you got, but this is not what I want to do. What I want to do digitally is exactly what I would do manually with scissors. The difference is that, doing it manually, I would get sheets smaller than A4, whereas if I do it digitally, I can print the page on a A4 paper. – Enrico Maria De Angelis Jan 13 '16 at 13:43
• In other words, I don't want to remove cut marks; I want to cut out white margins as indicated by marks. – Enrico Maria De Angelis Jan 13 '16 at 15:37
• @EnricoMariaDeAngelis: I honestly have no idea what that means. – Werner Jan 13 '16 at 17:02
• What would you do if you had to print a pdf document which has wide white margins and crop marks, using a home printer? I don't think you would print it as it is; indeed you would crop each page cutting out the white margins (crop marks would be cut out too, since they are in the outer part, the part which has to be cut out). I would you accomplish this task? – Enrico Maria De Angelis Jan 14 '16 at 7:51
• @EnricoMariaDeAngelis: Okay, so you want to remove the crop marks, but also zoom the page so you could fill what is printed in the page. Is that it? – Werner Jan 14 '16 at 8:22