I need to build this little program to allow a user to enter the number or numbers of the page(s) from a multipage PDF document and I know it can be done using Ghostscript directly.
For example, to extract pages 22-36 from a 100-page PDF file using pdftk: