Reputation: 82785
I have a single pdf file with three pages in it I need to turn this pdf into three seperate pdf pages is there any command line tool or script to do this. I am trying with pdftk, pdfcrop, and GS but so far nothing has worked out
Example: one.pdf has 1 page and that page has 3 pages in it. I need to divide this page into 3 seperate pages
Upvotes: 1
Views: 2805
Reputation: 2765
As far I understand you have three pdf pages stitched together side-by-side, constituting a single pdf page and you want separate any page into a single pdf page
as follows:
podofobox (from podofoutils)
Usage: podofobox [inputfile] [outpufile] [box] [left] [bottom] [width] [height]
Box is one of media crop bleed trim art Give values * 100 as integers (avoid locale headaches with strtod)
May be a tool to perform this task
take the mediabox info of your input pdf (for instance, with pdfinfo). You need to know the size (width and height) of your input pdf (having the three pages stitched side-by-side into one)
in my example, we have a 3-pages-side-by-side pdf
whose width and height are:
pdfinfo input.pdf | grep "Page size" Page size: 1785 x 841 pts
this is a 3-pages-side-by-side created stitching together 3 A4 size pdf pages
so, in order to get the width of a any single page constituting the input.pdf we need to divide (being known the height = 841 points) 1785 by 3 = 595
see grid I drawn
at this point we write this little one liner script
for i in `seq 0 59500 119000`; do podofobox input.pdf $i-out.pdf media $i 0 59500 84100; done
explanation: the script produces three single pdf pages, starting from 0 and finishing to 1190 points, 0, 595 and 1190, are the starting points of any of single pages stitched together. values are multiplied by 100 (needed by podofobox syntax)
this is an example for a pdf constituted of 3 A4 pages stitched side-by-side, if your page has different geometry, you simply need to divide by three and modify the script
Upvotes: 3
Reputation: 18139
You can use the burst option with pdftk. From the man page...
burst
Splits a single, input PDF document into individual pages. Also creates a report named doc_data.txt which is the same as the output from dump_data. If the output section is omitted, then PDF pages arenamed: pg_%04d.pdf, e.g.: pg_0001.pdf, pg_0002.pdf, etc. To name these pages yourself, supply a printf-styled format string in the output section. For example, if you want pages named: page_01.pdf, page_02.pdf, etc.,pass output page_%02d.pdf to pdftk. Encryption can be applied to the output by appending output options such as owner_pw, e.g.: pdftk in.pdf burst owner_pw foopass
Upvotes: -1
Reputation: 30269
Try using pdftk's 'burst' option.
example:
pdftk input.pdf burst
You can also use gs
(ghostscript) imagemajick
, graphicsmajick
and I'd expect cups
could also do it.
Upvotes: -1
Reputation: 298432
ImageMagick is what I use for all my CLI graphics:
convert foo.pdf foo-%01d.pdf
This produces three separate PDF files:
foo-0.pdf
foo-1.pdf
foo-2.pdf
Upvotes: 0