Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Needing help with different kinds of conditional logic in a custom PDF

Community Beginner ,
Jul 04, 2016 Jul 04, 2016

Ah the life of a developer - get handed something that a non-computer geek thinks is "easy" with an unrealistic timeline, and you've never done it before 🙂

I have been asked to take a custom-PDF built by someone in my group and make some changes.  I'm running Win7 and using Adobe Acrobat Pro DC.

What I need to do is basically variations around Conditional Logic; for example:

     If Checkbox1 is filled in, Checkbox2 becomes locked

     If Checkbox1 is filled in, ComboBox2 becomes mandatory

     If the user has filled out the PDF, saved it as "Customer_0123", and goes back in to make changes, can I highlight what was changed?

I am (very very) new to JavaScript and so I have been muddling through some documentation but the "most recent" document I have found from Adobe is 10 years old, and I'm not sure it's still relevant.

Any help would be appreciated...

Thanks

Chris

TOPICS
Acrobat SDK and JavaScript , Windows
932
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jul 04, 2016 Jul 04, 2016

The best way of associating scripts with check-boxes is to use the MouseUp event. In that event you can access the field's new value via event.target.value.

And yes, that's correct re the JS Console.

Translate
Community Expert ,
Jul 04, 2016 Jul 04, 2016

The code didn't change that much in the last 10 years, so what you found could still be relevant. The main difference could be how to access the fields and their actions. If you need help with that let us know.

The first two requests are relatively easy. The last one is not very clear... There's no "track changes" feature in PDF files, if that's what you mean.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 04, 2016 Jul 04, 2016

Thanks, this helps a lot.  I wasn't sure if I could have something in JavaScript where it said "on edit" or some such thing.  Can I lock the fields on Save?  If I can do that, then I can add the fields that could potentially change into a "Revision" section.

One other question that I've just come across, which is more high-level  (and based on your comment :-)).  I'm assuming that the Console view (CTRL-J) would be for document-wide javascript or doing hardcore coding / testing, and then the Actions tab with "Run A JavaScript" would be for field-specific actions (such as I'm doing)?

Thanks again!

Chris

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 04, 2016 Jul 04, 2016

The best way of associating scripts with check-boxes is to use the MouseUp event. In that event you can access the field's new value via event.target.value.

And yes, that's correct re the JS Console.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 04, 2016 Jul 04, 2016

Awesome, thanks so much 🙂

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 04, 2016 Jul 04, 2016

(one more quick question - is the version of JavaScript in Adobe "real" JavaScript, in that if I find a book on JS that shows how to set up a website but talks about making fields mandatory etc., can I use that code as the template for my PDF?  Or is it Adobe's version of JavaScript?)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jul 04, 2016 Jul 04, 2016

JavaScript in general consists of the Core, and application-specific extensions.

Web browser client-side JavaScript consists of the Core and webbrowser-client-side-specific extensions.

Server-side JavaScript consists of the Core ans server-specific extensions.

Acrobat JavaScript consists of the Core and Acrobat/PDF-specific extensions.

ActionScript consists of the Core and Flash-specific extensions

and so on…

So, for scripting in Acrobat/PDF, you have to know about the Core, the Acrobat/PDF-specific extensions, as well as the PDF document object model.

IMHO, the best reference about the Core is Flanagan's book "JavaScript, the definitive Guide (now in its 6th edition), published by O'Reilly. The reason why it is my favorite, it makes a clear distinction between Core and (well, probably the most common use) webbrowser-specific extensions. But because the distinction exists, it is easy to ignore the non-Core stuff.

And for Acrobat/PDF JavaScript, you will have to get the Acrobat SDK documentation, where you will find the Acrobat JavaScript documentation.

Hope this can help.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 04, 2016 Jul 04, 2016
LATEST

Thank you maxwyss!!  I was starting to feel overwhelmed with the amount of stuff out there on JavaScript so having these two resources will cut down dramatically on my reading time 🙂

Have a great day.

Chris

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines