I recently had a request to take a PDF file which contained multiple documents – one page each – and separate the documents out into individual files. The request was in a Microsoft Windows environment. I had used Ghostscript for such tasks in the past on Linux, and has pleased to find the software was also available for DOS based systems.
I can never remember the command line arguments for the program, so here’s how I did it for future reference. We’ll call the PDF file my_docs.pdf
and the output will be my_doc-i.pdf
, where i is the page number in the my_docs.pdf
. The Ghostscript program installed into C:\Program Files (x86)\gs
, and was accessable via PowerShell (although I probably could have also used cmd.exe).
C:\Program Files (x86)\gs\gs9.22\bin\gswin32.exe -sDEVICE=pdfwrite -sOutputFile=C:\Users\jason.favrod\tmp\my_doc-%d.pdf -dNOPAUSE C:\Users\jason.favrod\tmp\windows_server_book.pdf