PDFchomp

Created: 2012-03-20 15:08
Updated: 2013-12-03 20:53
c

README.markdown

This project is currently DEAD. Worked on it in September 2009.

PDFchomp: graphical PDF editor

PDFchomp screenshot

PDFchomp is an open source (GPL) PDF editor with a Python API. In the last version you could open PDF file, choose a crop rectangle with a mouse and save the cropped file.

PDFchomp depends on an open source MuPDF library (used by very nice PDF viewer SumatraPDF). The library is in C, so I wrapped it with Cython, and added basic capabilities for PDF editing. The result is a Python module mupdf, which can be used this way:

>>> pdf = mupdf.PDF('some_file.pdf')
>>> len(pdf) # number of pages
58
>>> pdf[0].bounds # first page bounds (MediaBox)
(0.0, 0.0, 595.0, 842.0)

Iterate through pages
>>> for page in pdf: print page.bounds
(0.0, 0.0, 595.0, 842.0)
(0.0, 0.0, 595.0, 842.0)
...

Cut 10 pixels from each edge and save changes to file
>>> pdf[0].bounds = (10, 10, 585, 585)
>>> pdf.fastsave('cropped_file.pdf')

Graphical interface is implemented in Python using PyGUI library.

Final binary works on Windows. Porting to Mac OS X and Linux shouldn't be very difficult - all libraries are cross-platform.

Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more