Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there a way to cut a single page PDF in half (vertically) from the command line on a Windows machine?

share|improve this question
    
No, I'm sorry for asking questions before actually thinking. Although I did a little research and stumbled across GhostScript, but it seems like you need a PhD in computer science in order to use it. –  Stryker84 Sep 27 '13 at 13:55
1  
@Stryker84 I've got the PhD and I'm still not sure that I fully understand GhostScript :-). But now you mention it... Maybe by having it enlarge the page into a 2-page poster. It just might be possible then to extract both pages (==halves) individually. –  Tonny Sep 27 '13 at 14:03
    
@Tonny That's a great idea, too! Thanks! –  Stryker84 Sep 27 '13 at 14:31

2 Answers 2

up vote 2 down vote accepted

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.

share|improve this answer
    
Thank you for your time and for explaining it so that even I could understand! That's very nice of you! –  Stryker84 Sep 27 '13 at 14:30

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:

http://www.mobileread.com/forums/forumdisplay.php?f=184

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.