I am looking for a tool to extract a given rectangular region (by coordinates) of a 1-page PDF file and produce a 1-page PDF file with the specified region:
# in.pdf is a 1-page pdf file
extract file.pdf 0 0 100 100 > out.pdf
# out.pdf is now a 1-page pdf file with a page of size 100x100
# it contains the region (0, 0) to (100, 100) of file.pdf
I could convert the PDF to an image and use convert
, but this would mean that the resulting PDF would not be vectorial anymore, which is not acceptable (I want to be able to zoom).
I would ideally like to perform this task with a command-line tool or a Python library.
Thanks!
using pyPdf, you could do something like this:
The following script found in http://snipplr.com/view.php?codeview&id=18924 splits each page of a pdf into 2.