Print Page | Close Window

Currently active field?

Printed From: Foxit's Planet PDF Forum
Category: Lets Talk PDF
Forum Name: PDF Forms and FDF
Forum Description: This conference is for users of PDF Forms, JavaScript and FDF Toolkits.
Printed Date: 20 Mar 2018 at 11:09pm
Software Version: Web Wiz Forums 11.10 -

Topic: Currently active field?
Posted By: jhmcmullen
Subject: Currently active field?
Date Posted: 07 Apr 2016 at 4:08pm
Hi, all. First post but I've read the forum for years off and on, but I'm still underserved in the knowledge area.


At the new job, one of my tasks is to prep software-generated forms for release. Specifically, I have to make text fields into date fields. (There are other kinds of fields, and other kinds of text fields, even.) 

So for any document, I don't know if there are text fields that should be date fields. I'm okay with opening them up, because I have to for other tasks, but I find the process of formatting a field to be somewhat tedious and lengthy. 

I have Acrobat X Pro. (Getting a different version is not an option.)

I want to:

Have a small dropdown menu or toolbar button that lets me apply the set of properties to the field that I need with one or three mouseclicks, so I don't have to wait for Acrobat to bring up the properties dialog, to switch tabs, to present the list, and so on.

I have looked at the Action wizard and it doesn't look like it does what I want in this version of Acrobat.

Use case

My thought is that I can select the field I want to change, right click to get the context menu (or have a button on the toolbar) and then click the entry or button to apply all the changes.

In the code to apply the changes, I'll make sure that the field involved is a text field and then make it a Date field by setting the field value to a Date() with the correct format.

Presumably this will be a user level script, and maybe I'll include some button to turn it on and off so it's not on all the time.


Which is easier, inserting into the existing context menu, a dropdown menu that's activated some way, or a button on a toolbar? None of those are areas I've worked in.

Is there a way to get the currently active field? I think the information is contained in the event structure ( so I suppose I could select the field, search for the appropriate event, and suck it out of 
  - If using a toolbar button, it's whatever field just lost focus except that I'll have to avoid other fields. Doable.

I am right about how you set the Date format, right?

I know that's a lot of questions and I have no cred here, but I hope you'll help.

If there's an existing thread or example that will do it or something close, just point me there.

Posted By: jhmcmullen
Date Posted: 07 Apr 2016 at 9:53pm
Well, poking around some more revealed one error to me. Using printd() just prints the current date into the field; it doesn't change the format as it is presented in Acrobat. Presumably choosing the list item on the Format menu sets a script to be run when the Format stage of event processing is hit (if I'm even saying that right) and the Acrobat program recognizes certain types of formats already. That makes it uglier.

Posted By: jhmcmullen
Date Posted: 07 Apr 2016 at 10:39pm
Got a bit farther. This article ( took me through the formatting part. I can now make an arbitrary text field into the proper kind of Date field.

The user interface is going to be a hassle, though, because I saw elsewhere that the ability to put up a toolbar was removed after Acrobat Pro 9. Still, a popup menu (popUpMenuEx() probably) will be sufficient. All I have to do is figure out what triggers it, and mouse entry would be sufficient. So, something like...

// some kind of toggle to enable

// at a document or Page level, look at every Field event
// If MouseEnter, get the field 
//    If the field type is text, pop up the menu
//        If the result is yes, apply AFDate_Format() and AFDate_Keystroke actions to the field
//    Otherwise do nothing

The next challenges will be figuring out what the toggle will be (because I don't want the menu appearing every time my mouse goes into a text field) and figuring out how we look at every event without modifying the fields in general.

Posted By: jhmcmullen
Date Posted: 08 Apr 2016 at 5:40pm
Just noticed this is a forum for forms and FDF, and I don't see FDF as in the scope of my problem. Sorry for posting in the wrong place. I'll re-post elsewhere.

Posted By: gkaiseril
Date Posted: 09 Apr 2016 at 4:13pm
You can specify the format for the date display in the util.printd method and the AFDate_Format function. You may also want to add some custom formatting and validating scripts so only valid dates can be entered. When one uses the provide UI in Acrobat all of this done as part of the formatting screen processing.

If I need a lot of control over form fields when creating a form, I work with Apache and create all the form fields there along with adding various layout an 0ptions for the fields. I can then export the form and fields to a PDF. Libre Office also has this capability/

Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.10 -
Copyright ©2001-2017 Web Wiz Ltd. -