I am extracting a pdf into images / swf and text with the help of SWFTools and XPDF.. I am running these in a PDF script.
But now I am trying to go one step further and try to get the TOC from the PDF is it possible to extract this information?
I found this with a little bit of searching. It looks rather promising.
PDFMiner: http://www.unixuser.org/~euske/python/pdfminer/index.html
Note: The tool is Python based, but you should be able to use the tool via shell access. Alternatively, you may be able to glean some useful info from the source code itself, as the project is open source.
From the Site:
dumppdf.py
dumppdf.py dumps the internal contents of a PDF file in pseudo-XML format. This program is primarily for debugging purposes, but it's also possible to extract some meaningful contents (such as images).
Examples:
$ dumppdf.py -a foo.pdf (dump all the headers and contents, except stream objects) $ dumppdf.py -T foo.pdf (dump the table of contents) $ dumppdf.py -r -i6 foo.pdf > pic.jpeg (extract a JPEG image)