43

Does anyone know of a good way to split a pdf's pages down the middle into two new pages?

To be clear, I'm not trying to split out already existing pages from a pdf; I am trying to create two new pages from an existing single page.

4

5 Answers 5

27

Try BRISS.

alt text

It lets you split each page into as many subpages as you want by defining regions with a GUI. It groups all similar pages into groups for you, so you can define regions for that group once.

It's cross-platform, free, and open-source.

1
  • It seems this increases file size (times "number of output pages per input page"), because it uses the original page content and a cropbox for each cropped page. If you need small file size, you can print the output file to PS and then convert to PDF, but you might lose quality then (for example, due to bitmap fonts).
    – tanius
    Mar 17, 2015 at 13:44
41

You can solve this with the help of Ghostscript. pdftk alone cannot do that (to the best of my knowledge). I'll give you the commandline steps to do this manually. It will be easy to script this as a procedure, also with different parameters for page sizes and page numbers. But you said that you can do that yourself ;-)

How to solve this with the help of Ghostscript...

...and for the fun of it, I've recently done it not with an input file featuring "double-up" pages, but one with "treble-ups". You can read the answer for this case in this other response.

Your case is even simpler. You seem to have something similar to this:

+------------+------------+   ^
|            |            |   |
|      1     |      2     |   |
|            |            | 595 pt
|            |            |   |
|            |            |   |
|            |            |   |
+------------+------------+   v
             ^
            fold
             v
+------------+------------+   ^
|            |            |   |
|      3     |      4     |   |
|            |            | 595 pt
|            |            |   |
|            |            |   |
|            |            |   |
+------------+------------+   v
<---------- 842 pt -------->

You want to create 1 PDF with 4 pages, each of which has the size of 421 pt x 595 pt.

First Step

Let's first extract the left sections from each of the input pages:

gs \
    -o left-sections.pdf \
    -sDEVICE=pdfwrite \
    -g4210x5950 \
    -c "<</PageOffset [0 0]>> setpagedevice" \
    -f double-page-input.pdf

What did these parameters do?

First, know that in PDF 1 inch == 72 points. Then the rest is:

  • -o ...............: Names output file. Implicitely also uses -dBATCH -dNOPAUSE -dSAFER.
  • -sDEVICE=pdfwrite : we want PDF as output format.
  • -g................: sets output media size in pixels. pdfwrite's default resolution is 720 dpi. Hence multiply by 10 to get a match for PageOffset.
  • -c "..............: asks Ghostscript to process the given PostScript code snippet just before the main input file (which needs to follow with -f).
  • <</PageOffset ....: sets shifting of page image on the medium. (Of course, for left pages the shift by [0 0] has no real effect.)
  • -f ...............: process this input file.

Which result did the last command achieve?

This one:

Output file: left-sections.pdf, page 1
+------------+  ^
|            |  |
|     1      |  |
|            |595 pt
|            |  |
|            |  |
|            |  |
+------------+  v

Output file: left-sections.pdf, page 2
+------------+  ^
|            |  |
|     3      |  |
|            |595 pt
|            |  |
|            |  |
|            |  |
+------------+  v
<-- 421 pt -->

Second Step

Next, the right sections:

gs \      
    -o right-sections.pdf \
    -sDEVICE=pdfwrite \
    -g4210x5950 \
    -c "<</PageOffset [-421 0]>> setpagedevice" \
    -f double-page-input.pdf

Result:

Output file: right-sections.pdf, page 1
+------------+  ^
|            |  |
|     2      |  |
|            |595 pt
|            |  |
|            |  |
|            |  |
+------------+  v

Output file: right-sections.pdf, page 2
+------------+  ^
|            |  |
|     4      |  |
|            |595 pt
|            |  |
|            |  |
|            |  |
+------------+  v
<-- 421 pt -->

Last Step

Now we combine the pages into one file. We could do that with ghostscript as well, but we'll use pdftk instead, because it's faster for this job:

pdftk \
  A=right-sections.pdf \
  B=left-sections.pdf \
  shuffle A B \
  output single-pages-output.pdf
  verbose

Done. Here is the desired result. 4 different pages, sized 421x595 pt.

Result:

+------------+ +------------+ +------------+ +------------+   ^
|            | |            | |            | |            |   |
|     1      | |     2      | |     3      | |     4      |   |
|            | |            | |            | |            | 595 pt
|            | |            | |            | |            |   |
|            | |            | |            | |            |   |
|            | |            | |            | |            |   |
+------------+ +------------+ +------------+ +------------+   v
<-- 421 pt --> <-- 421 pt --> <-- 421 pt --> <-- 421 pt -->
4
  • 3
    Pretty! You should really use this in every answer if you want to keep getting upvotes for free!
    – Ivo Flipse
    Mar 1, 2011 at 22:29
  • 2
    The second step only worked for me when I used a negative offset: "<</PageOffset [-421 0]>> setpagedevice". I guess it depends on the orientation of the original file. Excellent answer nonetheless. :)
    – moraes
    Mar 31, 2013 at 22:38
  • 1
    To me the second step also worked with the minus sign
    – Rafareino
    Aug 14, 2014 at 22:20
  • 1
    It works perfectly fine but the PDF file size indicates that each page now contains the entire image from the double page it came from but half of it hidden outside the page boundary. That confuses my printer so some pages print as blank pages. Is the a way to crop everything outside the visible page somewhere in the process?
    – mgd
    Dec 5, 2022 at 16:08
18

Thanks to @marttt and their answer in Unix & Linux.

You can use mutool (which comes as part of mupdf):

mutool poster -x 2 input.pdf output.pdf

You can also use -y if you want to perform a vertical split.

3
  • This is a simple solution, thanks. Unfortunately, there is no way to shift the content on the page to adjust the margins - for that use the method described by Kurt Pfeifle. Mar 16, 2017 at 13:47
  • Segmentation fault
    – nilon
    Apr 12, 2020 at 22:14
  • After installing the package mupdf, I had to install the package mupdf-tools to get mutool (in Ubuntu 18.04)
    – Deleplace
    Dec 5, 2021 at 23:27
0

To expand upon @Kurt's answer (since I don't have enough reputation points to comment) first make sure the dimensions you use is not based on the Crop Box dimensions if they are different from the Media Box dimensions. The output size is based on Media Box dimensions, but the offset seems to use the Crop Box dimensions.

For a gatefold page that had a 20.0833 x 13.833 media box and a 19.25 x 13.0 crop box which was the same as the trim box in my document, to split it into two pages on Ubuntu, for the left side:

gs -o left.pdf -sDEVICE=pdfwrite -g7230x9960 -c "<</PageOffset [0 0]>> setpagedevice" -f gatefold.pdf

The right side:

gs -o right.pdf -sDEVICE=pdfwrite -g7230x9960 -c "<</PageOffset [-693 0]>> setpagedevice" -f gatefold.pdf

And then stitched them with pdftk left.pdf right.pdf output final.pdf.

An alternative would be to set the crop box to the same as the media box; then the offset would be -723. But then the crop would have to be reset to trim in order for the pages to appear seamless. Otherwise, set media to crop.

3
  • Note, after splitting the pages with these command options, the media boxes do not change. Only the crop changes. If you split one page into multiple pages, the new pages keep the media box dimensions from the old page. Need sed to modify the media box dimensions. Though don't know how to set media box to crop without including numbers in the command.
    – motorbaby
    Jul 27, 2015 at 21:49
  • Oops. I mean the new pages keep the crop box dimensions from the old page.
    – motorbaby
    Jul 28, 2015 at 19:08
  • Found a bug with Acrobat PDFs. Visually, cropBox dimensions can be seen in Set Page Boxes in Acrobat. But cropBox dimensions after using Ghostscript to divide the gatefold kept the old page dimensions on another level. This could be seen in Preflight Analyze info in Acrobat. After adjusting the crop in Acrobat on the right side of the left page temporarily to an arbitrary number and then returning it to 0, the other box dimensions (bleed, art, and trim) also adjusted. This fixed the problem where the cropBox data still showed the old page dimensions. The right page was a little different.
    – motorbaby
    Jul 28, 2015 at 20:08
0

Krop (Python) & PDFscissors (Java) haven't been mentioned yet, check them out if you have f.e. pdfnup-ped lecture notes you want to reverse back into a proper presentation PDF..

http://arminstraub.com/software/krop

https://sites.google.com/site/pdfscissors/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .