Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

Security on Acrobat Form

Avatar

Level 4

My client gave me a form with Changing the Document: Not Allowed and Document Assembly: Not Allowed.

Is there any way that I can make myself a copy, as the developer, of this form with full access? Somehow copying the content and creating a new file? My problem is that I have an Acrobat javascript that will not work in LiveCycle (copied below). In Acrobat, this script is in the button properties, with a .js file in Acrobat>javascript as a trusted function. It works in Acrobat, but I can't get it to work in LC.

newDocName = "";
f1 = this.getField("topmostSubform[0].Page1[0].Last_Name[0]").valueAsString;
if (f1!="") newDocName += f1 + " ";
f2 = this.getField("topmostSubform[0].Page1[0].First_Name[0]").valueAsString;
if (f2!="") newDocName += f2 + " ";
f3 = this.getField("topmostSubform[0].Page1[0].Date[0]").valueAsString;
if (f3!="") newDocName += f3 + " ";
f4 = this.getField("topmostSubform[0].Page1[0].Email[0]").valueAsString;
if (f4!="") newDocName += f4;

newDocName = newDocName.replace(/[\\,\/,\:,\*,\?,\",\<,\>,\|,\,,\n,\r]/g,"");

docPath = this.path+"";
docPath = docPath.substring(0, docPath.lastIndexOf("/")+1);

mySaveAs(this,docPath+newDocName+".pdf");

13 Replies

Avatar

Level 4

For example, is there a way to copy the entire form, except for the Print Form button, into a new file that I could create in Acrobat and add my javascript to that file/button?

Avatar

Level 7

You could flatten the form, OCR it in Acrobat and then import it into Designer. If nothing else you can always do a screenshot and OCR it. Neither of these is the best option but they're better than starting from scratch. Out of curiosity, why not just have the customer send you the form with the protection taken off?

Avatar

Level 4

Yes, I agree that these options aren't useful in this case. And to answer your question, I did ask for the document with full access, but the customer couldn't provide one. I think that she created the form in LiveCyle, which, I gather, is not compatible with Acrobat tools for objects. Do you have any suggestions on how to mofify this javascript, which works in Acrobat on a button, so that it will work in LiveCycle?

newDocName = "";
f1 = this.getField("topmostSubform[0].Page1[0].Last_Name[0]").valueAsString;
if (f1!="") newDocName += f1 + " ";
f2 = this.getField("topmostSubform[0].Page1[0].First_Name[0]").valueAsString;
if (f2!="") newDocName += f2 + " ";
f3 = this.getField("topmostSubform[0].Page1[0].Date[0]").valueAsString;
if (f3!="") newDocName += f3 + " ";
f4 = this.getField("topmostSubform[0].Page1[0].Email[0]").valueAsString;
if (f4!="") newDocName += f4;

newDocName = newDocName.replace(/[\\,\/,\:,\*,\?,\",\<,\>,\|,\,,\n,\r]/g,"");

docPath = this.path+"";
docPath = docPath.substring(0, docPath.lastIndexOf("/")+1);

mySaveAs(this,docPath+newDocName+".pdf");

I tried putting this in the Script Editor with MouseUp, but it doesn't work.

Avatar

Level 7

There is no getField attribute in Designer javascript, that's why the script is failing. Can you post the form you're trying to work with? It might be helpful to see what exactly you're working with.

Avatar

Level 4

Sure. Here's the form. The Print Form button should fire the javascript. You'll see a Print function there already on Click.

Avatar

Level 7

After fooling around with the form a bit, I really don't have a good solution for you. I tried flattening the pdf and importing it into Acrobat, but it just dumps the form back into Designer for editing.

Avatar

Level 4

Thank you for taking a look at it. Do you know how to modify the javascript I have to that it will work in LiveCycle? So that it conforms to the LiveCycle Object Model?

Avatar

Level 7

I don't know of any way to change the name of the document dynamically in Designer. I've seen a lot of people asking for this so that they can give unique names to forms when submitting by email but I've yet to see a solution.

Avatar

Level 4

I didn't think changing the name would work, but I don't have much experience with Acrobat or LiveCycle. So my approach now is to try to make this javascript work in LiveCycle on a MouseUp event. Do you know how to modify this script so it will work in LiveCycle?

newDocName = "";
f1 = this.getField("topmostSubform[0].Page1[0].Last_Name[0]").valueAsString;
if (f1!="") newDocName += f1 + " ";
f2 = this.getField("topmostSubform[0].Page1[0].First_Name[0]").valueAsString;
if (f2!="") newDocName += f2 + " ";
f3 = this.getField("topmostSubform[0].Page1[0].Date[0]").valueAsString;
if (f3!="") newDocName += f3 + " ";
f4 = this.getField("topmostSubform[0].Page1[0].Email[0]").valueAsString;
if (f4!="") newDocName += f4;

newDocName = newDocName.replace(/[\\,\/,\:,\*,\?,\",\<,\>,\|,\,,\n,\r]/g,"");

docPath = this.path+"";
docPath = docPath.substring(0, docPath.lastIndexOf("/")+1);

mySaveAs(this,docPath+newDocName+".pdf");

Avatar

Level 7

Again, there's no way I know of to pull data out of the form and use it to rename the document. Your script pulls out the last name, first name, date and email address information and uses it to rename the document. To the best of my knowledge this isn't possible in a Designer form.

Avatar

Level 4

This script works in a form in Acrobat. I add a Run a Javascript action and edit it to include this script and when the user clicks the Print form button, it both prints and saves with the new filename. My assumption is that the javascript can be converted somehow to the LiveCycle syntax so that when the button is clicked, it prints and saves with a new filename. Do you know of a way to convert this javascript?

Avatar

Level 7

Acrobat's version of javascript is not the same as the javascript used in Designer. Acrobat scripting has access to several things that Designer does not have access to. To get the script to work you're going to have to get the form into an AcroForms format and to do that you'll have to either recreate the form in Acrobat Forms or flatten the form (print it to the Adobe pdf printer) and overlay all the interactive objects. I understand why you'd be frustrated by this, but scripting in Acrobat and scripting in Designer can be very different from one another.

Avatar

Level 4

You're absolutely right about the differences between Acrobat and Designer. I found a good article that discusses AcroForms and XFA.

http://www.acrobatusers.com/blogs/thomp/so-what-difference-between-acroforms-and-xfa

Thank you for all your comments.