arminstraub / krop Goto Github PK
View Code? Open in Web Editor NEWA simple graphical tool to crop the pages of PDF files, written in Python/Qt
Home Page: http://arminstraub.com/software/krop
License: GNU General Public License v3.0
A simple graphical tool to crop the pages of PDF files, written in Python/Qt
Home Page: http://arminstraub.com/software/krop
License: GNU General Public License v3.0
Whenever I try to run either the Ubuntu Universe packaged version of the app or the snap version in Lubuntu 19.10, I receive the following error:
ValueError: PyCapsule_GetPointer called with incorrect name
The error described here:
https://github.com/leo-editor/leo-editor/issues/1106
... was similar, so I tried applying the fix there to the latest code from the git repo (without a full understanding of the issue). I have added the following to vieweritem.py at line 25:
except ValueError: QtWebKitWidgets = None
I then ran:
python3 setup.py build
sudo python3 setup.py install
Krop now runs for me.
Is there going to be python310 support?
Traceback (most recent call last):
File "/usr/bin/krop", line 33, in <module>
sys.exit(load_entry_point('krop', 'console_scripts', 'krop')())
File "/usr/bin/krop", line 22, in importlib_load_entry_point
for entry_point in distribution(dist_name).entry_points
File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 919, in distribution
return Distribution.from_name(distribution_name)
File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 518, in from_name
raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: No package metadata was found for krop
I am just opening this issue to be notified if macOS ever gets supported.
BTW: Have you seen https://www.willus.com/k2pdfopt/? It's pretty good, though I mostly use it for non-mathy PDFs. It doesn't play that well with equations that take multiple vertical lines.
I would be very useful if the GUI could show the equivalent command line that give the same resoult of what you are doing with the GUI.
Whit this feature you could decide how crop your pdf using GUI (which is more visual an easy in order to decide the area to crop) but later you could build a script to repeat the job in future without having to repeat everything from the beginning.
What a great little app!
However, after processing a pdf with krop
, the table of contents "metadata" seems to be deleted. Is there any way to retain it? (makes sense for ereaders too, navigating to a specific part is especially cumbersome on slower and smaller devices if you can't just select a chapter)
Hi,
I installed from AUR using yay in Manjaro.
This is the output that I get:
$ krop
(python:9314): Gtk-WARNING **: 22:00:05.427: Unable to locate theme engine in module_path: "clearlooks",
(python:9314): Gtk-WARNING **: 22:00:05.428: Unable to locate theme engine in module_path: "clearlooks",
Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/krop/pdfcropper.py", line 28, in <module>
from pyPdf import PdfFileReader, PdfFileWriter
ModuleNotFoundError: No module named 'pyPdf'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/bin/krop", line 33, in <module>
sys.exit(load_entry_point('krop', 'console_scripts', 'krop')())
File "/usr/lib/python3.10/site-packages/krop/application.py", line 81, in main
from krop.mainwindow import MainWindow
File "/usr/lib/python3.10/site-packages/krop/mainwindow.py", line 46, in <module>
from krop.pdfcropper import PdfFile, PdfCropper, PdfEncryptedError, optimizePdfGhostscript
File "/usr/lib/python3.10/site-packages/krop/pdfcropper.py", line 34, in <module>
raise RuntimeError(_msg)
RuntimeError: Please install PyPDF2 (or its predecessor pyPdf) first.
On recent versions of Ubuntu, the following should do the trick:
sudo apt-get install python-pypdf2
(or, if using python3) sudo apt-get install python3-pypdf2
I am totally sure that python-pypdf2 is installed:
$ yay -Ss python-pypdf
aur/python-pypdf3 1.0.5-1 (+0 0.00)
Pure-Python PDF library for splitting, merging, cropping, and transforming PDF pages.
aur/python-pypdf2-git b17382f-1 (+5 0.00)
PyPDF2 library for Python3
aur/python-pypdf2 1.26.0-2 (+20 1.23) (Installed)
A utility to read and write PDFs with Python
Is there a workaround, something like softlinking to the already installed library?
A better and more portable installation method:
pipx
krop
: pipx install krop
pipx inject krop python-poppler-qt5 pypdf2
Hi developers,
Thank you for this tool!
I found some PDF files can't be cropped, with this error:
The following unexpected error has occured:
file has not been decrypted
In console
Traceback (most recent call last):
File "krop-0.5.1/krop/mainwindow.py", line 340, in slotKrop
raise err
File "krop-0.5.1/krop/mainwindow.py", line 315, in slotKrop
cropper.addPageCropped(pdf, nr, c, rotate=rotation)
File "krop-0.5.1/krop/pdfcropper.py", line 86, in addPageCropped
page = pdffile.reader.getPage(pagenumber)
File "/usr/lib/python3.6/site-packages/PyPDF2/pdf.py", line 1176, in getPage
self._flatten()
File "/usr/lib/python3.6/site-packages/PyPDF2/pdf.py", line 1505, in _flatten
catalog = self.trailer["/Root"].getObject()
File "/usr/lib/python3.6/site-packages/PyPDF2/generic.py", line 516, in __getitem__
return dict.__getitem__(self, key).getObject()
File "/usr/lib/python3.6/site-packages/PyPDF2/generic.py", line 178, in getObject
return self.pdf.getObject(self).getObject()
File "/usr/lib/python3.6/site-packages/PyPDF2/pdf.py", line 1617, in getObject
raise utils.PdfReadError("file has not been decrypted")
PyPDF2.utils.PdfReadError: file has not been decrypted
I find the feature set of krop quite interesting and because at my job I have to work with Windows, I'd interested whether there are any plans on supporting the Windows platform as well?
It could be possible to use an automated *.exe
creation mechanism like some other projects (e.g. neovim uses appveyor - see the config file).
Started Krop and followed instructions as per the "Help" menu tab: open pdf file, create selection: ok.
Buttons Zoom, Previous, Next and Trim all work as expected.
Clicked the Krop! button [smiling face :-)] and expected a File Save Dialog to save the cropped pdf, but nothing happened.
Tried different distributions (Snap, Flatpak and Apt): no difference (except that the Apt-version is rather old).
Also started krop from the command line to view possible error messages but nothing shows when pressing the Krop! button.
Any tips welcome!
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.4 LTS"
just a small info: there is also a flatpak for krop available at flathub ...
PS: Ganz herzlichen Dank für das Tool ...
config.py curently includes code:
krop/config.py: import sip
krop/config.py:sip.setapi('QString', 2)
krop/config.py:sip.setapi('QVariant', 2)
Not sure it's purpose, but recent sip/PyQt5 releases use a name-spaced PyQt5.sip module instead. So either drop this or switch to PyQt5.sip (depends if the setapi calls are really needed anymore or not)
On Ubuntu 18.10 the latest version doesn't save the window size after a restart. Same goes for the state of "fit in view".
I would like to use krop for automatic trimming of a bunch of images via the command line. I want krop to change the pdf as little as possible and only crop the margins.
I realized, that by default krop is using the Optimize PDF option via ghostscript, which I think compresses the images and even tries to replace fonts if they are not available in the system. This is something I would like to avoid
I suggest adding a command-line option --gs-optimize
that would be False by default, so one could use e.g.
krop --go --autotrim --gs-optimize --output fout.pdf fin.pdf
First: I like this app, thank you. But running in Kubuntu 20.04 (Focal):
The snap version of Krop does not see gs which is not a snap; the gs option is grayed out.
Krop fails - crashes - with Could not find object
when used on a page that was excerpted from a multi-page PDF with pdftk, as in e.g. pdftk in.pdf cat 35 out.pdf
.
Anyway, I installed Krop directly from Github and now it does all I want it to do, which is cutting out individual articles from NASA Tech Briefs, producing small output files. Except now I won't know when and how to upgrade to a new version.
Hello @arminstraub,
Thank you for the great software!
I remember that krop used to have a feature that that could display the pages in transparent mode (it was around 10 years ago), but in the current version I couldn't find that option anymore. Is it hidden somewhere?
Thanks in advance for your reply.
I would love for this program to be translatable. Is this on the roadmap?
Hi Armin,
Flathub is a build and distribution platform for Linux apps, packaged in
a way that makes them portable and running on all major distributions.
Anyone can submit an app (we're not doing it for profit), but one of the
requirements is to reach out to the application's authors if they would
like to help with maintenance and thus making that distribution channel
considered official.
I'm volunteering to make a flatpak for krop to be published in https://flathub.org/.
The usual maintenance for new releases is just changing version string and
the file checksum. The rest is done by flathub's build infraestructure.
It's understandable if you can't commit to maintaining it, I can do the new
version updates as I'm the original packager and interested in having
krop on flathub, but we'd like to know if you are not against
distributing it on Flathub in general.
Thank you,
Nelson
Hi @arminstraub,
I think it would be a good idea to port the snap config files and snap creation to this repo...
e.g. a push to this repo would trigger a new candidate
version of the snap app...
what do you think? I did not update the snap app for a while, most changes that I made were throughing qt4 away...
Steps to port snap krop to this repo:
Let me know what you think 🔥
To push the popularity of this app and simplify the installation you could publish it on Flathub as a Flatpak.
BTW, I would totally love to see the following features from your ToDo list soon:
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)
Many thanks for the work you've already done!
Hi,
Is it possible to have --autotrim
either automatically generate a "Trim margins" crop box for each individual page, or compute the largest crop box for the full page range? I have some very long (>1000 pages) documents I'd like to make more readable on a small screen e-reader, and i'd rather not check each crop box individually :)
Thanks!
"PdfFileReader is deprecated and was removed in PyPDF2 3.0.0. Use PdfReader instead."
Hi!
I've noticed that krop uses PyPDF2. Is there a reason for not putting it in the setup.py as a dependency?
PyPDF2 has changed a lot since April. We try hard not to break stuff (see deprecation process), but we also want to move forward. As we modernized the API, a lot of the names changed. It's mostly switching from camelCase to snake_case, but see CHANGELOG "deprecation" for details.
There is no such package in the portage tree any more, but there is dev-python/python-poppler-qt5, which should be fine too.
And portage has older version of this package, could it worth updating it? I found one bug here https://bugs.gentoo.org/616432
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.