7 Using Ghostscript to get page size
7.1 Answer 1
Unfortunately it doesn’t seem quite easy to get the (possibly different) page sizes (or *Boxes for that matter) inside a PDF with the help of Ghostscript.
But since you asked for other possibilities as well: a rather reliable way to determine the media sizes for each page (and even each one of the embedded {Trim,Media,Crop,Bleed}Boxes) is the commandline tool pdfinfo.exe.
This utility is part of the XPDF tools from http://www.foolabs.com/xpdf/download.html.
You can run the tool with the -box parameter and tell it with -f 3 to start at page 3 and with -l 8 to stop processing at page 8.
Example output
7.2 Answer 2
Meanwhile I found a different method. This one uses Ghostscript only (just as you required). No need for additional third party utilities.
This method uses a little helper program, written in PostScript, shipping with the source code of Ghostscript.
Look in the toolbin subdir for the pdf_info.ps file.
The included comments say you should run it like this in order to list fonts used, media sizes used
I did run it on a local example file, with commandline parameters that ask for the media sizes only (not the fonts used). Here is the result: