monaghan has asked for the wisdom of the Perl Monks concerning the following question:

Just wanted to thank everyone on this site for their help. This is my second post and you have all be very helpful.

What I am try to do here is create a table of contents page and my perl script is already using the module PDF::API2. I have all of my pages created and now I need to create a TOC that says which page each section starts on. My initial thoughts were to call $pdf->openpage(#) and have that number written to a stack that would be called in the TOC but I'm not sure what to do if a certain portion of the page rolls onto two or more pages. Also note that I will always have same amount of sections in the TOC so really all I need to worry about is what page they are on.

I'm kinda at a lose at where to start with this but would greatly appreciate the help. Thanks!

Replies are listed 'Best First'.
Re: Creating a table of contents
by dragonchild (Archbishop) on Jul 31, 2008 at 00:40 UTC
    Sounds like it would be sanest for you to insert a blank page where the TOC would be, build your file while keeping track of pertinent info, then go back and open that blank page and put your TOC in.

    Another solution would be to build each piece separately. So, you build your file and keep track of info. Then, you build your TOC as a completely separate PDF. There are dozens of ways of concatenating PDFs together, many of which use ghostscript (gs). YMMV


    My criteria for good software:
    1. Does it work?
    2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
Re: Creating a table of contents
by jethro (Monsignor) on Jul 31, 2008 at 01:59 UTC
    There is a way to generate pdf that gives you a table of contents for free: By generating a latex file and then using dvipdf to make a pdf out of that. Table of content generation is built into latex

    I don't know if that is possible or even advisable for what you want to do, since you didn't say. But if you know some latex already and you need to generate professional looking text, it might be just the right solution for you