Chris Chris - 2 years ago 196
PHP Question

Extract TOC of PDF?

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?

Answer Source

I found this with a little bit of searching. It looks rather promising.


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: 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).


$ -a foo.pdf
(dump all the headers and contents, except stream objects)

$ -T foo.pdf
(dump the table of contents)

$ -r -i6 foo.pdf > pic.jpeg
(extract a JPEG image)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download