Split multi page PDF file into single pages
Solution 1
The most recent version of Ghostscript (v9.06) can do this too. Here is the commandline to be used inside a cmd.exe
'DOS-Box' window on a 32-bit Windows system:
gswin32c.exe ^
-o original_page_%03d.pdf ^
-sDEVICE=pdfwrite ^
-sPDFSETTINGS=/prepress ^
original-multipage.pdf
-o ...
: this indicates the name of the output file(s).
%03d
: this part of the filename will be translated into 3-digit numbers, padded by leading 0
s, starting from 001
for the first page.
-sPDFSETTINGS=...
: is an optional parameter; if used will ensure that all used fonts are embedded and some other settings which in general ensure a high quality output.
Ghostscript is available for Windows. (The link above leads you to the installers: gs906w32.exe and gs906w64.exe. Scroll down to find them...).
Solution 2
You can use Pdftk
exec("pdftk " . $pdflargeFile . " burst output " . $outputPath);
Muhammad Qasim
Updated on June 26, 2022Comments
-
Muhammad Qasim almost 2 years
Possible Duplicate:
Split PDF documents into separate pages using PHP (or possibly perl)How can I split a multi-page PDF file into distinct single page PDF files in PHP on Linux server? Are there any PHP libraries or free command line tools available to do this?
-
Muhammad Qasim over 11 yearscan this be used on windows also???
-
Baba over 11 yearsyes it runs on windows see pdflabs.com/docs/install-pdftk
-
Muhammad Qasim over 11 yearsDoes this snippet will work on windows with ghostscript v9.05?
-
Muhammad Qasim over 11 yearsIt didn't work. Are you sure its for splitting pdf file or for joining???
-
Muhammad Qasim over 11 yearsKurt, can you please explain it a bit more. I didn't get it. Thanks
-
Baba over 11 yearsSee : pdflabs.com/docs/pdftk-cli-examples
Split Select Pages from Multiple PDFs into a New Document pdftk A=one.pdf B=two.pdf cat A1-7 B1-5 A8 output combined.pdf
-
Baba over 11 yearsUse
pdftk largepdfile.pdf burst
and tell me that you get -
Muhammad Qasim over 11 yearsYes thats what I wanted but using "burst" in this way also creates a text file. Anyway to escape this?
-
Muhammad Qasim over 11 yearsOK. Will I be able to use it on Linux in the same way? if not what I would need to change?
-
Baba over 11 years@Muhammad Qasim it something simple and not enough for you to change
-
Muhammad Qasim over 11 yearsI think .exe will not run on Linux (don't know much about Linux), how to install it for Linux and how to add it to the PATH?
-
Kurt Pfeifle over 11 years@MuhammadQasim: Why, do you think, did I explicitely write 'the most recent version of Ghostscript'? And why did I even quote that version, you think?! -- So no, it doesn't work with v9.05.
-
Kurt Pfeifle over 11 years@MuhammadQasim: I updated the answer to add some better explanation of the individual parameters used.
-
Martin Schröder over 11 years@MuhammadQasim: Do you need that for Linux (as you say in your question) or Windows or ...?
-
Baba over 11 yearsIt Supporst Linux FeeBDS , Ubuto or SuSE RMP .... already given you installation link pdflabs.com/docs/install-pdftk
-
MrCalvin over 6 yearsif it does require java it should have been specified in the answer