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

Scripting with PDFTK

jeffersonstreetjoe
Registered: Feb 11 2009
Posts: 16

I had this in another thread, but let me start a new one: I am hoping to be able to run a script to run through many PDF documents and attach an index file (.pdx).

To do it for one file .. File, Properties, Advanced tab, Browse, and choose ..

I was hoping someone could help me put this into a script. Any help would be greatly appreciated!

My Product Information:
Acrobat Standard 9.0, Windows
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
You can use the "addIndex" method of the 'search' object.

search.addIndex({cDIPath: "/c/program files/adobe/Acrobat 5.0/help/exchhelp.pdx", bSelect: true});

George Kaiser

jeffersonstreetjoe
Registered: Feb 11 2009
Posts: 16
i'm not all too familiar with implementing javascript and Adobe. i've read up on it a little bit.

The impression I get is I make a js file, put it in some directory, and it will run every time Adobe opens.

Unforuntately, my javascript is not there anymore (meaning I used to be knowledgeable, but no longer) and I do not know exactly which directory to place the file.

Any more help?
laharris
Registered: Mar 29 2010
Posts: 4
I tried using your syntax: search.addIndex({cDIPath: "/D/Temp/IndexTest/SPMATDOCINDEX.pdx", bSelect: true});

I am getting an error that says it cannot open my PDX file. I check it and it is not a read only file.

Any suggestions?
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
Does the file exist?

Was the index build successful (check the log file)?

Is there a subfolder with 2 'idx' files in it?

George Kaiser

laharris
Registered: Mar 29 2010
Posts: 4
Yes, the SPMATDOCINDEX.pdx file exists as does the subfolder containing index.idx and index1.idx. And yes the indiex build was successful according to the log file.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Unfortunatley there is no way using JavaScript that you can set the search index for a PDF. This operation would require a plug-in. But as GKaiseril suggests you could add a document script to the PDF that examines and sets up the search index parameters when the PDF is opened.

"addIndex" adds the index to the global list of indexes searched, it's not specific to the current document. I do not know why your addIndex function is not working. But I do know that this functionality does work becaused I've used it before. You might want to take a look at this article:
http://www.acrobatusers.com/tutorials/custom-document-search-using-javascript


You might also want to use some of the other search functions to examine the list of indexes that are already set before trying to add a new one. It could be failing because it already exists.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.html]http://www.adobe.com/devnet/acrobat/javascript.html[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

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