6

I am new to Latex and this place, so I have a few very simple questions, so simple that I do not find the answers:

  1. To automatically get rid of white spaces around an image on a PDF document I would like to insert into Latex, I should use PDFcrop, right?

  2. Is PDFcrop included in the Latex basics or is it an external program?

  3. If it is part of Latex, is it part of a package? Which one?

  4. By what command do I activate the cropping (I am assuming, in the graphix environment)?

dan1789
  • 73
  • pdfcrop is a script distributed as part of texlive it uses tex to crop pdf files. You should not normally need it very often, why do your pdf files have excess space to be cropped? It is a commandline program. – David Carlisle Feb 28 '17 at 15:30
  • an alterntaive to producing a new cropped pdf you can specify viewport option to \includegraphics and just display part of the original pdf without actually editing the file. – David Carlisle Feb 28 '17 at 15:32
  • Hi, I am not sure what you are trying to tell me with your answer (script, textlive etc.), so could you dumb it down for me in reference to my questions above please. I have made a graph in excel, printed it to pdf via pdfforge, but I cannot get it to just print the graph, so its on a big white page. Since I will be doing a lot of graphs, I am looking for some way to get the cropping done automatically. – dan1789 Feb 28 '17 at 15:34
  • Also, this is a problem millions of people have, I am aware and have read about it, but I just need somewhere to start, which would be by knowing whether PDFcrop is "in" Latex and whether/how I can activate its cropping function. CTAN, for example tells me "A Perl script that can ei­ther trim pages of any whites­pace bor­der, or trim them of a fixed bor­der. " No idea what a perl script is, and the readme does not say much really. – dan1789 Feb 28 '17 at 15:35
  • Perl is a programming language, and a Perl script is (essentially) a computer program written using that language. pdfcrop is typically used via a command line interface (e.g the command prompt in Windows), where you write out the commands you want to do, instead of clicking a button in a GUI. So you would open a command prompt, navigate to the folder with the PDF using cd, and then write pdfcrop filename.pdf, which will generate filename-crop.pdf. – Torbjørn T. Feb 28 '17 at 16:46
  • many people has had problems running pdfcrop, error 127. To solve it you need to be sure pdfcrop can find ghoscript. And the executable has to ve renamed to gs.exe and the version must match the version required by pdfcrop. Yo can run pdfcrop --verbose --debug with with your pdf to see the path and executables it looks for in your computer. – skan Nov 14 '17 at 16:51

2 Answers2

5

pdfcrop is is a command that you run to edit the pdf, you do not call it from within latex. It will be one of the commands installed when you installed tex.

But for your use case you probably do not need to edit the pdf file with pdfcrop, just display part of the original.

so for example

\documentclass{article}

\usepackage{graphicx}

\begin{document}

\fbox{\includegraphics[width=5cm,clip]{duck.pdf}}



\fbox{\includegraphics[viewport=900 450 1200 750,width=2cm,clip]{duck.pdf}}


\end{document}

Includes a complete pdf file then includes the same file just showing part of it. there is no need to use pdfcrop to crop the file.

enter image description here

PDFcrop can be useful if you need to automatically guess the cropping region based on the white space. If so just use a command such as

pdfcrop original.pdf new.pdf

to make a new pdf file, there are several options, see pdfcrop --help

David Carlisle
  • 757,742
1

Instead of pdfcrop, you may want to try briss (http://briss.sourceforge.net/), which has a graphical user interface. Open the file, mark a rectangle around the image and click crop.