Is there a way to cut a single page PDF in half (vertically) from the command line on a Windows machine?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.
Sign up to join this communityIs there a way to cut a single page PDF in half (vertically) from the command line on a Windows machine?
That is technically very complicated...
A PDF does NOT contain an image of the page (that would be easily cuttable in 2 pieces).
In stead a PDF contains a script in a (Postscript like) computer language that instructs the reader how to build the page(s).
This script doesn't necessarily work in a logical top to bottom order. It is just as valid to build the page from the bottom upwards or work from left to right.
Or elements of the page are specified in a random order.
(Render the footer, render the header, draw a border around the entire page, text-block on the bottom-right containing "this text". Box on top-left containing this image, etc.)
This means that there is no clear bottom-half or top-half to the script. It would be very difficult to figure out what part should go in the first half and which goes in the second part. And some stuff needs to be duplicated (like an embedded font used in both halves) or needs to be modified into 2 pieces (like an image or border that crosses the cutting line).
The easiest way I can think of would be a "PDF to image" converter that would first render the entire page as an image. Then cut the image and create new PDF's from the bottom and top image.
You need 3 programs to do that.
And you will loose the nice things of the original PDF (like search-ability and select-copy-paste in the text-area's).
I am not aware of any program that can do this in 1 step. PDF2Image and vice-versa and batch-image manipulators are easy to find.
There are two common ways to cut/crop a PDF file: (1) convert it to an image, like already mentioned, and (2) render the page multiple times using cropping directives. Option (2) generally works the best since it preserves most of the original aspects of the PDF file (highlightable text, for example). Several programs will perform option (1) and/or option (2)--k2pdfopt (1&2), briss (2), sopdf (2), papercrop (1&2) to name a few. I know k2pdfopt best:
If by "vertically in half" you mean two columns, use this:
k2pdfopt -grid 2x1x0 -w 0.5s -h 1s file.pdf
If you want a top and bottom half of the page, then use this:
k2pdfopt -grid 1x2x0 -w 1s -h 0.5s file.pdf
The output (if file name is file.pdf) will be in file_k2opt.pdf.
k2pdfopt is available as open source (there are MS Windows binaries) from http://willus.com/k2pdfopt/
If you are just trying to fit the PDF to an e-book, check the "sticky" threads here: