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

Saving with name derived from fields

wdrspens
Registered: Jul 22 2008
Posts: 94
Answered

I use Adobe Acrobat 9 professional, and do not have access to LiveCycle Designer, so please do not recommend any solution involving LiveCycle Designer.
I have a very specific, and probably very easy to resolve, problem.
I have an Acrobat Form designed in 9 Professional which has numerous fields, some of which are calculated and read only, but most of which are the result of some input, a keyboard entry, or a mouse click, etc.
There are two specific fields, “Surname”, which has to be entered from the keyboard, and “TodayDate” which is filled automatically when the field is opened by a document level script –
// Populate the TodayDate field with today's date
var d = new Date();
this.getField("TodayDate").value = util.printd("dd-mmm-yyyy",d)
My problem is:
I want to design a (non-printable) button that will save the data in all the fields (except those that have been calculated and are read only) with the file name “yymmddSurname.fdf” where yy is the 2 digit year, mm is the two digit month, and dd is the 2 digit day of the contents of the TodayDate field, and Surname is, of course, the contents of the Surname field. Thus the save file will be something like 040808Smith.fdf. I also want the person who presses the button to have the choice about where to save it, and, if he/she wants to, to change the name of the file saved. However, at the same time (that could be before the file is saved by the person filling in the form) the file, with its specified filename “yymmddSurname.fdf”, needs to be sent by email to two given email addresses.
Any suggestions would be gratefully received.
David

My Product Information:
Acrobat Pro 9.0, Windows
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
> ...please do not recommend any solution involving LiveCycle Designer.No problem. :^)

> I have a very specific, and probably very easy to resolve, problem.Most of what you want can be done using the doc.exportAsFDF() JavaScript method, but certain security restrictions apply as detailed in the Acrobat JavaScript reference. You can specify which fields you want included in the FDF.

> I also want the person who presses the button to have the
> choice about where to save it, and, if he/she wants to, to
> change the name of the file saved.This should not be a problem. You could first prompt the user (e.g., with app.alert) with the proposed file name and location and ask if it's OK. If Yes, include the path in your exportAsFDF call; otherwise don't include the path/filename in the exportAsFDF call and the user will be prompted for the location and filename.

> However, at the same time (that could be before the file is
> saved by the person filling in the form) the file, with its specified
> filename “yymmddSurname.fdf”, needs to be sent by email to
> two given email addresses.That might be a problem. The doc.mailForm() method will do most of what you want, but it does not allow you to specify a file name for the FDF attachment.

George
wdrspens
Registered: Jul 22 2008
Posts: 94
Thank you very much for the hint, but I have searched the JavaScript for Acrobat API Reference book for exportAsFDF and can see some of the things that it does, but cannot see how or where to use it.

Do I put whatever JavaScript I eventually decide to code into an event on the button, and if so which event?
Page 287 of the Reference Book, which deals with exportAsFDF, gives no indication of how I can specify the file name.
How do I extract the yy, mm, dd from the TodayDate field?
How do I concatenate those values extracted with the Surname field?
How do I then specify which fields to export? Do I have to list them all individually, and if so, what do I use to separate the fields? Can I use a conditional statement to exclude read only fields?

I am sorry but you are dealing with a gifted ingenue not an experienced professional and there is so much to learn.

David
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Yes, a call to the code can be placed in a button, but because of security restrictions, the exportAsFDF statement must be in a folder-level JavaScript in a trusted function. What this means is that all users of this form have to install a file that contains the JavaScript on their machine. Will that be a problem? Also, do you expect this to work for users who only have Reader? We can address the rest of your questions after you answer these.

George
wdrspens
Registered: Jul 22 2008
Posts: 94
It will not be a problem installing a file that contains the JavaScript on an individual's machine, there are probably only three machines involved, at most, but the other two will only have Reader. Only I have Acrobat 9 Professional.
Thank you very much
David
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
David,

In order to save an FDF, the users will have to have more than Reader. Acrobat Standard is sufficient. The only way it can work with Reader is if the file is given extended rights by Adobe's LiveCycle Reader Extensions product, which seems unlikely in this case. Note that you cannot use Acrobat (e.g., Advanced > Extend Features in Adobe Reader) to give the necessary rights. If you can get those users upgraded, we could show you what JavaScript you'd need to make this work.George
wdrspens
Registered: Jul 22 2008
Posts: 94
Geroge,
Thank you, that is very helpful indeed.
Is it possible, as an alternative, to design an "Import Data" button for use with Reader?
I can email the .fdf file to the person who has it on their disk, but can that person import that data if she only has Reader?
Thank, again,
David
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
You could do something like that if with the help of a web server, but that's getting complicated.

But you could send the entire (partially) filled-in PDF and the user would be able to make changes to the form and save it, if the PDF is given save rights in Acrobat.

If these folks will be using a lot of different forms, the upgrade may make sense as it would open up a lot of possibilities for efficient workflows. No, I don't own any Adobe stock, nor do I work for them. :^)

George
wdrspens
Registered: Jul 22 2008
Posts: 94
George

How could you :) I would never suggest anything of the sort!

Thank you very much, I think I will settle for the user sending me the completed form, keeping her own hard copy, and getting me to let her have a filled in form if she requires one.

You have been very helpful and saved me a lot of work and experimentation.

Thanks

David