Copy link to clipboard
Copied
Hello everyone,
I created a form with some JavaScript functionality. It works in Adobe Acrobat DC, but it doesn't work in Reader on our company website.
Is there a reason for this?
Thanks,
Jake
1 Correct answer
I’m going to guess that the marketing department opened it in Preview on OSX and then saved the file… or inadvertently saved it after some minor change. Preview... without warning... removes scripts from PDF form fields every chance it gets.
J-
Copy link to clipboard
Copied
Acrobat Reader doesn't support all JavaScript features.
Copy link to clipboard
Copied
What kind of "functionality"?
Copy link to clipboard
Copied
All I am doing is adding JavaScript to form fields:
function check () {
//Foot Options is the name of the radio button group
//Javelin is the name of the radio button
//If the selected radio button isn't called Javelin
if(this.getField("Foot Options").value != "Javelin"){
//Don't allow both to be selected
this.resetForm("Top Housing");
}
}
check();
Copy link to clipboard
Copied
resetForm takes either nothing or an array as a parameter. See the brackets around your field name below.
function check () {
//Foot Options is the name of the radio button group
//Javelin is the name of the radio button
//If the selected radio button isn't called Javelin
if(this.getField("Foot Options").value != "Javelin"){
//Don't allow both to be selected
this.resetForm(["Top Housing"]);
}
}
check();
Copy link to clipboard
Copied
You're right, but resetForm will work if you specify only a single field's name, even if it's not in an array.
Copy link to clipboard
Copied
Did you open the form in Acrobat Reader?
Copy link to clipboard
Copied
The form has been put on a website as a link. It seems to be opening in the browser instead of in Acrobat Reader. Could this be the problem?
Edit: Adobe Acrobat Reader is Enabled in the browser. So even though it opens from the browser, it looks as though the PDF opens inside Reader.
Copy link to clipboard
Copied
Are you sure? What browser are you using?
Copy link to clipboard
Copied
Yes I've just checked on Chrome and Explorer.
However, I have just found out that the JavaScript actions are no longer on the form fields.
Is there any way this could have happened, other than someone doing it manually?
My original PDF has the JavaScript action. I sent it to our Marketing department to put on the website and now the JavaScript actions aren't there.
Copy link to clipboard
Copied
Chrome uses an internal PDF plugin, not the Adobe one.
Copy link to clipboard
Copied
Would this remove JavaScript from Form Fields?
All the fields are still named the same as when I created them.
Copy link to clipboard
Copied
No, but it will not execute them correctly, most likely.
Copy link to clipboard
Copied
I’m going to guess that the marketing department opened it in Preview on OSX and then saved the file… or inadvertently saved it after some minor change. Preview... without warning... removes scripts from PDF form fields every chance it gets.
J-
Copy link to clipboard
Copied
This sounds like the most likely reason Joel, thank you
I wasn't aware that this happens in Preview on OSX.
Thanks everyone for your comments.
Copy link to clipboard
Copied
Thanks Joel. Is there anything that we can do to avoid this?
Copy link to clipboard
Copied
Put a sign over the coffee machine that reads "Preview is poison to PDF"?
Seriously though... simply installing Adobe Reader will cause it to take over the file type association so the default won't be to open in Preview. If that's not going to work for you a bit of training might help.
One thing I've been considering is to create a little tool that will pop up an alert when a PDF is opened that contains form fields and has been saved by Preview basically telling people that the form data is probably corrupted.
Any thoughts on that?
Copy link to clipboard
Copied
Love the sign idea, but won't work since my pdf files don't go to a company they are for people literally all over the world.
Some may have Reader installed (most do), however now that browsers make it "easy" to view pdf files, many just open in the browser and go from there.
Creating that little tool sounds like a great idea! Will that tool work being just attached to the file itself (basically "server side" where the file is stored) or would it only work it could be installed on the client machine?
It's just annoying that you get a great piece of javascript to do these awesome calculations, but in certain instances they don't work because of how people are viewing/utilizing the pdf form. There has to be some way around this..like a setting when developing the form to not let them preview or something (basically have to download and use Adobe Reader and not the browser or previews... I'm sure that's asking too much...
Open to any and all ideas though...thanks, Joel!
Copy link to clipboard
Copied
nicolek13929741 wrote
It's just annoying that you get a great piece of javascript to do these awesome calculations, but in certain instances they don't work because of how people are viewing/utilizing the pdf form. There has to be some way around this..like a setting when developing the form to not let them preview or something (basically have to download and use Adobe Reader and not the browser or previews... I'm sure that's asking too much...
Actually... it's not asking too much. Actually it's quite simple. You just create a "warning" and put it on a layer. The you add a JavaScript to the document that, if it's able to run, hides the layer. This limits the viewers that can be used without showing the layer to Adobe's and just a few others. You can completely restrict it to just Adobe products using the same technique but different conditions in the "if" statement.
You can see an example here...
http://www.adobe.com/showcase/casestudies/mcgladreydyn/casestudy.pdf
Copy link to clipboard
Copied
Hey Joel - that's a great example!!! Where do I go to learn how to do this???
Copy link to clipboard
Copied
Do you have a TARDIS? I learned it over the course of 20 years.
Though a good place to start is pdfscripting.com
Copy link to clipboard
Copied
LOL - my TARDIS has been on the fritz.
Thanks for the link - I'll see if I can figure it out. Unless you're for hire and could teach this?

