These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

How to create a TOC PDF file for hundreds of PDF files to put on CD?

fablau
Registered: Oct 22 2010
Posts: 4
Answered

Hello here,
I need to create a CD rom with hundreds of PDF files on it organized in folders and subfolders, and was wondering if there is any easy way to create a PDF-table-of-contents (maybe by using bookmarks) preserving the folder-sub-folder structure to allow the user to browse the contents easily. I have seen many CDs out there with such a system but I have no idea how to do it!
 
Any suggestions and tips are very welcome.
 
Thank you in advance to anyone.
 
Best,
Fab.

My Product Information:
Acrobat Standard 8.1.7, Macintosh
rbogie
Registered: Apr 28 2008
Posts: 432
the basics: create a TOC with your favorite word processor and print/publish it to PDF. then open TOC.pdf in Acrobat and use the link tool to create a link (action: open a file) for each title in the TOC. in each target file create a bookmark or button (action: open a file) that points to TOC.pdf.
UVSAR
Expert
Registered: Oct 29 2008
Posts: 1357
If you're processing hundreds of PDF files then doing the TOC links by hand is unrealistic to say the least.

Acrobat can't easily help as its JavaScript API doesn't support the functions you'd need to scan your folder tree into an array. The most practical solution would be to use a PDF library for Java, Perl or PHP, and run a script from a command prompt that scans the folder structure and creates a PDF with links for each file - it can take a bit of coding to write the script in the first place, but then whenever your files change you can simply re-run it.

Of course you need to be careful how you structure the links so they stay relative - fully-qualified links won't work on a CD if the user's drive letter is different.

See this post for more info:

http://acrobatusers.com/forum/it/pdf-creation-and-manipulation-java-packages


fablau
Registered: Oct 22 2010
Posts: 4
Thank you guys for your replies.

Yes, I have hundreds of PDF files organized in folders and sub-folders, so an automated system is absolutely needed. I would be particularly interested in a PHP implementation since I am a PHP developer. Do you know where I can find a PDF library for PHP?

Thank you again very much!

Best,
Fab.
UVSAR
Expert
Registered: Oct 29 2008
Posts: 1357
Take a look at FPDF for starters.There's also an add-on library from Setasign which allows you to import existing PDF files as "templates" and add stuff to them, called FPDI.Note that both are free, but are limited to working with early versions of PDF and basic operations such as placing text and graphics on the page, and making simple links. Neither will support advanced features such as rich media or JavaScript buttons, but they'll do what you need.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Well actually, you could easily use Acrobat JavaScript in a Batch Script to create a TOC doc.
The batch processes walks all files and subfolders. I opens each file in Acrobat and applies the batch sequence commands to it.

So your Batch script could create a new PDF doc on the first file and then add a reference to this doc for each file processed.


Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

fablau
Registered: Oct 22 2010
Posts: 4
Thank you USVAR for your suggestion, I will check that out.

Thank you also thomp, your solution sounds pretty easy but I really don't know where to start playing with Acrobat Javascript... anyone is aware of some 'ready to use" script for that purpose?

Thank you again.

Best,
Fab.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Unfortunately the batch scripting isn't trivial and I don't know of any scripts ready made for the purpose.

Something like this:

var bMakeDoc = false;
try{global.TODDoc}
catch(e){bMakeDoc = true:}

if(bMakeDoc)
global.TODDoc = app.newDoc();

var rootPath = new RegExp("/c/..Path to CD folder../");
var cPath = this.path.replace(rootPath,"");
global.bookmarkRoot.createChild(this.documentFileName,"app.openDoc(cPath)");


The code adds bookmarks to a PDF that's created when the first doc is processed. The bookmarks use a script to open a doc at a relative path. The relative path is created by slicing out a portion of the complete path. The part that is sliced out is hard coded in "rootPath". The TOC doc must of course be located at the top of the root for the relative paths to work. The TOC doc will be open at the end of the process so the user will have to manually save it.

This is just one simple way it could be done. The files could also be listed on the PDF in a real TOC listing with links, if you wanted to get fancy.

As another suggestion you might want to look at the bookmark tool at: www.evermap.com


Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

fablau
Registered: Oct 22 2010
Posts: 4
Thank you very much thomp, I will checkout your suggested resources. evermap.com solution looks fantastic and exactly what I was looking for.

All the best,

Fab.