39
25
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.
39
25
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.
26
Try BRISS.
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.
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 – 2015-03-17T13:44:35.093
37
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 ;-)
...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.
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 -->
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 -->
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 -->
1To me the second step also worked with the minus sign – Rafareino – 2014-08-14T22:20:43.883
3Pretty! You should really use this in every answer if you want to keep getting upvotes for free! – Ivo Flipse – 2011-03-01T22:29:11.423
2The 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 – 2013-03-31T22:38:01.240
10
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.
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. – Ján Lalinský – 2017-03-16T13:47:31.820
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.
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 – 2015-07-27T21:49:02.503
Oops. I mean the new pages keep the crop box dimensions from the old page. – motorbaby – 2015-07-28T19:08:07.580
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 – 2015-07-28T20:08:53.877
See also http://stackoverflow.com/q/13345593/321973
– Tobias Kienzler – 2014-12-01T10:40:48.037Possible duplicate of Convert PDF 2 sides per page to 1 side per page
– fixer1234 – 2016-02-12T06:24:29.160why do you want to do this? getting smaller pages? – akira – 2011-01-19T06:19:27.130
Well MS Office is not a freeware, but if you have MS Office 2007, then you could just save documents as PDF files and do as you please... – Owen – 2011-01-19T06:49:40.197