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

Add Filename within file

direwolf
Registered: Nov 18 2010
Posts: 2
Answered

Hi,
 
I'm trying to figure out automating inserting the filename of my pdf into my pdf file.
I found how to create a script to insert the filename in a form field using:
event.value = this.documentFileName.replace(/\.pdf$/g,"");
But it seems I have to open the file to get that form field to populate with the filename.
 
What I'd like to do is be able to have a pdf template file that contains the javascript rule.
Copy that pdf file.
Change the filename of that pdf file.
Batch process the file so that the javascript executes and the file is saved in another file format with the filename inserted into the form field.
 
I'm basically trying to create a 'header tag' file to use as an identifying file.
 
If I open the pdf, I can get the javascript to execute and insert the filename.
But I'm trying to figure out how to automate things so that simply changing the filename and then batch processing the file to save it as a postscript file gives me a .ps file with the filename inserted.
 
Hope that makes sense!
thanks.

My Product Information:
Acrobat Pro 9.3.1, Macintosh
direwolf
Registered: Nov 18 2010
Posts: 2
Accepted Answer
I figured it out (funny how if you post a question in a forum and quit thinking about something for a bit, the answer can occur to you, huh?)
If I reset the form and then set the value, it works just like I want it to.

this.resetForm("Header");
event.value = this.documentFileName.replace(/\.pdf$/g,"");

Thought I'd post this in case it helps someone down the road.
(Of course, replace Header on the reset line above with whatever your form field is named.)
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
You can also set the field's 'defualtValue' to the files name and the reset button clear the field and display the optional default value.

George Kaiser