What is krop?
krop is a simple graphical tool to crop the pages of PDF files.
- The functionality of krop is perhaps best indicated by some screenshots.
- krop should work on any recent Linux distribution, see how to install krop. I don't know if krop can be used on Windows or Mac after a sufficient amount of tinkering: please let me know in case you succeed.
- It is written in Python and relies on PyQT, python-poppler-qt5 and PyPDF2 for its functionality.
- It is free software, released under GPLv3+ in the sole hope that you or someone else may find it useful.
- A unique feature of krop, at least to my knowledge, is its ability to automatically split pages into subpages to fit the limited screensize of devices such as eReaders. This is particularly useful, if your eReader does not support convenient scrolling. (In fact, I wrote krop to be able to read mathematical papers on my Nook.)
- Possible alternatives to krop include PDF-Shuffler and briss.
- Please report bugs to firstname.lastname@example.org. Patches with improvements would, of course, be wonderful.
What krop fails to do
Unfortunately, there is no simple way to eliminate unnecessary/invisible parts of a pdf. krop only adjusts which parts of a PDF are displayed; the original content is still there in the file and will, for instance, show up when editing the file in inkscape. As a result, krop is not suited for the following:
- censor a PDF document
- decrease the size of a PDF file
That being said, since version 0.5.0, you may have some success in decreasing the size of the PDF (and even censoring some parts) using the option to use Ghostscript to optimize the final PDF.
|krop 0.5.1||2018/10/27||Armin Straub|
|*||Replace and extend the README file with a MarkDown version (thanks to Eduardo Montenegro for doing this).|
|+||Add a manpage.|
|*||Fix a Qt5 related bug when selecting filename for saving (thanks to Lin-Buo-Ren for reporting this).|
|krop 0.5.0||2018/02/11||Armin Straub|
|+||Use Ghostscript to optionally optimize the final PDF (thanks to Mathias Rav for the idea and code).|
|krop 0.4.13||2017/07/22||Armin Straub|
|+||Added the command line option --go, which outputs a PDF using the choices from --autotrim, --rotate and --whichpages, without opening the krop GUI (thanks to Mirko Weihrauch for the idea).|
|+||Padding for auto trimming can be specified as in CSS using one to four values. This option is now also available on the command line as --autotrim-padding. (Thanks to Jonah Langlieb for providing sanity checks!)|
|*||Fix incorrect string handling when opening files from the command line using python3 (thanks to Giuliano Costantini for observing and fixing this).|
Please read below how to install krop, if you are unsure which file to download.
|krop-0.5.1.tar.gz||41.72 KB||krop 0.5.1 (source code)||824|
|krop-0.5.1.ebuild||916 Bytes||krop 0.5.1 (ebuild)||518|
|krop_0.5.1-1_all.deb||21.97 KB||krop 0.5.1 (Debian package)||1602|
|krop-0.5.0.tar.gz||41.60 KB||krop 0.5.0 (source code)||1380|
|krop-0.5.0.ebuild||916 Bytes||krop 0.5.0 (ebuild)||949|
|krop_0.5.0-1_all.deb||20.64 KB||krop 0.5.0 (Debian package)||2261|
The source code for krop is now also available on GitHub: https://github.com/arminstraub/krop
Give krop a try without installing
Download the source package, say krop-0.5.1.tar.gz, and start krop directly:
$ tar xzf krop-0.5.1.tar.gz $ cd krop-0.5.1 $ python -m krop
This should work using either version 2 or 3 of Python. Note that on some distributions, including Ubuntu 18.04, you need to replace python -m krop with python3 -m krop in order to use Python 3.
This will only work if PyQT, python-poppler-qt5 (or the older python-poppler-qt4) as well as PyPDF2 (or the older pyPdf) are already installed on your system (either via your distribution or installed manually). You also need to make sure that these packages are installed for the appropriate version of Python.
You should be able to install krop on any recent Linux distribution. The following distributions already include krop:
- On Fedora all you need (thanks to Christopher Meng) is:
$ yum install krop
- On Gentoo it suffices (thanks to Andreas Huettel) to run (you might be asked to enable experimental packages):
$ emerge krop
On the other hand, Debian packages are available for distributions based on Debian, which further includes kubuntu, Ubuntu and Linux Mint. Finally, you can install krop from sources on any distribution such as Arch.
After installing krop by one of these methods, it should be available on the command line as
krop and you can call it without parameters or with one parameter specifying the PDF file you would like to open. If you install krop using the Debian package (which is recommended as it allows for easy uninstalling), it should also become available in the desktop menu as well as in the context menu of PDF files.
Install as snap
Thanks to Carlos Gomes Martinho, krop can also be installed as a snap on most linux systems.
Install from Debian package
The following instructions have been tested using a standard installation of kubuntu, version 18.04. Little adjustment should be needed for other Debian-based distributions. For older distributions, you will need to download older packages (try version 0.5.0) or install krop in some other way.
For this approach you need to download only a Debian package, say, krop_0.5.1-1_all.deb.
If gdebi is installed (its command line version resides in the package gdebi-core), then
$ sudo gdebi krop_0.5.1-1_all.debshould be sufficient.
Otherwise, we install the dependencies by hand, that is:
$ sudo apt-get install python3-poppler-qt5, python3-pypdf2 $ sudo dpkg -i krop_0.5.1-1_all.deb
Install from source package
First, you need to install PyQT, python-poppler-qt5 (or the older python-poppler-qt4) as well as PyPDF2 (or the older pyPdf), so that they are each available from within python. You also need to make sure that these packages are installed for the appropriate version of Python.
It should then be sufficient to download the source package, say krop-0.5.1.tar.gz, and issue something along the lines of:
$ tar xzf krop-0.5.1.tar.gz $ cd krop-0.5.1 $ sudo python setup.py install
As for when trying out krop, on some distributions, including Ubuntu 18.04, you need to replace python with python3 in order to use Python 3.
If you wish to install krop into the desktop menu, you can either do this by hand or use the included krop.desktop file:
$ xdg-desktop-menu install --novendor krop.desktopIt may take a while for the menu entry to appear.
For options to uninstall krop, see http://stackoverflow.com.
A few tricks
- If you press
Trim Marginson a page without selections, then
kropwill automatically create a region for the full page with the margins trimmed.
- If you are cropping a PDF file with many pages, then you may have some exceptional pages which need to be cropped in a different way then the other pages. In that case, the option
Selections apply towill be useful to you.
- You can use
krop --goon the command line (without the GUI) to automatically
- extract certain pages,
- rotate pages, or
- trim empty margins (the margins are determined from the
$ krop --go --rotate 90 --autotrim -o ~/output.pdf input.pdfTo get around the error "cannot connect to X server", you can prefix this command with
xvfb-run(in the package
xvfbon Debian and Ubuntu).
--helpto get a list of all possible arguments (for instance,
--initialpage 5starts krop with the fifth page open).
- To add the dimensions of your own eReader to the 'Fit screen of device' choices, you can edit the configuration file. The location of this file may differ from system to system, but a good place to start looking is ~/.config/arminstraub.com/krop.conf. Don't forget to adjust the counter
size=after adding your entries in the
- If you run into the error "multiple definitions in dictionary" while cropping a file, then this is because pyPdf is too strict. You can either upgrade to PyPDF2 or proceed as indicated in this bug report.
|+||Allow automatically trimming margins of every page individually|
|+||Make Ghostscript features (like exporting to PDF 1.7) available in krop UI|
|+||Automatize splitting pages in common ways (for instance, one page into two equally sized pages)|
|+||Specify aspect ratio of crop regions|
|+||Clone regions (and keep them linked)|
|+||Make it possible to save and later reuse regions|
|+||Preserve meta data, table of contents and bookmarks when cropping|
|+||Option to overlay pages in order to improve making selections|
|+||Better support for handling a large number of files|