Thread: split pdf files with ghostscript API

  1. #1
    Registered User
    Join Date
    Jul 2010

    split pdf files with ghostscript API

    hey guys,

    not sure if this is the right board. anyway: i'm trying to split a pdf file into multiple parts (example: file has 5 pages, page 1 and 2 should be one file, 3 to 5 the other one) in my C++ project.

    i decided to go with the ghostscript API. first i looked at the "official" documentation and the ghostscript tutorial from thomas merz.

    however i haven't been able to find out how to split pdf files with GS.
    if i understood the documentation correctly, i'd have to initialize an array with various arguments and call some (seemingly four) functions.

    my problem is that i don't know which arguments the GS API needs to split a pdf file (and apparently i wasn't smart enough to figure it out on my own). does somebody here have some experience with ghostscript (and is willing to help me ;-)?

    thanks in advance

  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    You should be able to do this much more simply with a command-line tool. For example, with pdftk the command to split a 5-page file into two files with pages 1+2 and 3+4+5 would be
    $ pdftk input.pdf cat 1-2 output pages12.pdf
    $ pdftk input.pdf cat 3-5 output pages345.pdf
    (I think, I just read the man page. Might be incorrect.)

    Another useful sub-command for pdftk is "burst", which takes each page from a pdf and creates a separate file out of it.

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell

    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ:

    My website:
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using c++ standards
    By subdene in forum C++ Programming
    Replies: 4
    Last Post: 06-06-2002, 09:15 AM
  2. API Reading Files, handle is always -1
    By Xei in forum C++ Programming
    Replies: 13
    Last Post: 05-06-2002, 10:16 PM
  3. reinserting htm files into chm help files
    By verb in forum Windows Programming
    Replies: 0
    Last Post: 02-15-2002, 09:35 AM
  4. displaying text files, wierd thing :(
    By Gades in forum C Programming
    Replies: 2
    Last Post: 11-20-2001, 05:18 PM
  5. more header files
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 10-28-2001, 01:56 PM