• Welcome to the new COTI server. We've moved the Citizens to a new server. Please let us know in the COTI Website issue forum if you find any problems.
  • We, the systems administration staff, apologize for this unexpected outage of the boards. We have resolved the root cause of the problem and there should be no further disruptions.

Adobe Acrobat PDF Forms & Javascript

Enoff

SOC-13
Anybody have any experience with making PDFs and using Javascript? I am just curious about the possibilities, everyone seems to have a PDF reader on their device. I've made some complicated forms when I worked for the university, even had it attached to a script online to submit data. But I was wondering if you couldn't make say a character generator with it, just curious.
 
Funny you should ask something like that... :)

I've been working on two projects the fast few weeks, both related to the fact that I have just started running my first Traveller game since the late-80s that are related to what you asked.

The first is a MS Word-based character sheet for MgT. I started with a simple form, then added some drop down boxes for the skills, and careers. Even linked the career-branch selection so if you pick say "Rogue" it will only show you the specialties for the Rogue career. Then I added logic to calculate the ability modifiers (have a Dex of 12, get +2, etc) and even range modifiers for ranged weapons. Unfortunately taking it any further than that would have required me to start over completely and re-write everything in VisualBasic and I just didn't see the value in that. But it still is a pretty cool form, and I can convert it to a PDF, but it will loose the automation parts.

The second was something I mentioend in another thread. Taking the JavaScript-based Megatraveller Character Creation tool hosted here and using it as a base to create one for MgT. The fun part is that when I started this project (on Presidents Day) I didn't know any JavaScript. Turns out the MgT process is probably a bit to complicated and involved to do this in JS, but I am slugging away at it and learning. I've got it to the point where it generates the UPP, creates a homeworld, and takes you through the first term of a career (without events and mishaps). But then it goes boom. Still working on understanding how JS works when it comes to controlling the flow of an application.

I didn't know that you could use JS to automate a PDF form though. That provides a *very* interesting idea for the next step of the character generator app. I was wondering how I could then get the info into a nice format to print, and that would be the answer.

Of course I would have to get to that point where the application is complete and that is a big if. There is way to much data for me to type in as JS variables, objects, and arrays to do the complete process for MgT. Though I guess for other versions of Traveller (like CT or MgT) it might be easier. I've tried creating characters for T5 by hand and still aren't sure I've gotten it right, so I won't even go there with the thought of automating it.
 
So YOU'RE the guy! That MT chargen program is very nicely done.

Yes, you can embed JavaScript into PDF, where they can interact with form fields. Last time I tried it, it felt rather clunky, but that was years ago.

If you want to see a good example of JS in PDF in action, check out EABA ("End All Be All Gaming System"). They're on Wikipedia. Anyhow, they have a builder that's basically a PDF form with embedded JavaScript. I find it impressive.
 
So YOU'RE the guy! That MT chargen program is very nicely done.

As much as I wish I could take credit, I did not write that app.

I wish I knew who did since they put everything in one file which made it much easier for me to download and look at the code. I've re-used some parts of it (like the die rolling and for now the UI), but MgT chargen is much different, and a lot more complicated. I would love to thank the person who did write it.


Yes, you can embed JavaScript into PDF, where they can interact with form fields. Last time I tried it, it felt rather clunky, but that was years ago.

If you want to see a good example of JS in PDF in action, check out EABA ("End All Be All Gaming System"). They're on Wikipedia. Anyhow, they have a builder that's basically a PDF form with embedded JavaScript. I find it impressive.

Hmm, sounds like something worth taking a look at when I am ready.
Thanks!
 
Anybody have any experience with making PDFs and using Javascript? I am just curious about the possibilities, everyone seems to have a PDF reader on their device. I've made some complicated forms when I worked for the university, even had it attached to a script online to submit data. But I was wondering if you couldn't make say a character generator with it, just curious.

Not all PDF readers handle javascript nor forms in sane ways.

It's a bit of a pain to do, but with the right approach, such forms become quite useful.

Acrobat is a poor tool for programming them, tho'.
 
If you want to see a good example of JS in PDF in action, check out EABA ("End All Be All Gaming System"). They're on Wikipedia. Anyhow, they have a builder that's basically a PDF form with embedded JavaScript. I find it impressive.

Looking at one of their worksheets, vehicle builder I think, yes very interesting. I was reading where you can use variables and functions with Javascript in the PDF probably 9+ versions.

eaba01.jpg


Seems like it works like the maker tables in T5 (never looked at it, just going by what I've read here) and does all the calculations.
 
Digging around in the vehicle worksheet looks like the drop down menus submit a value that is put into a variable. Have to dig deeper to see if these are later used in a function.

eaba03.jpg


eaba04.jpg
 
Looking at one of their worksheets, vehicle builder I think, yes very interesting. I was reading where you can use variables and functions with Javascript in the PDF probably 9+ versions.

eaba01.jpg


Seems like it works like the maker tables in T5 (never looked at it, just going by what I've read here) and does all the calculations.

Javascript works Acrobat 5+, actually. Tho' 8+ saw vast improvements over prior.
Most 3rd party PDF readers didn't support javascript until after Acrobat 8 specification. Some still don't, especially on Android.

Greg only works with acrobat 9 and later.
 
Thanks Aramis, I am curious what the Adobe reader on my iPad1 supports, need to look at its version.
 
Back
Top