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

Is there any internal property that indicates when a form field was last modified?

Community Beginner ,
Jan 05, 2018 Jan 05, 2018

Copy link to clipboard

Copied

Greetings,

I am working with a client on a fairly long form for manufacturing process validation.  It's 115 pages and has nearly 4,000 user editable fields.

They want to be able to verify when each field has been entered by users.  While we can certainly use signatures to confirm that fields were filled in before the signature, the order in which fields are completed and the time between field completion matters to them from a process management standpoint.

My (perhaps simple) question is this:  does Acrobat track the time when a field's content was last updated?  If it does, does it also track the user name? Since it knows what's been changed since a signature was applied I'm hopeful that it's tracking that information internally and I can access it programmatically.

If not, has anyone ever used Javascript on the fields to try and accomplish the same thing?

Thanks!

TOPICS
Acrobat SDK and JavaScript

Views

1.9K

Translate

Translate

Report

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 , Jan 07, 2018 Jan 07, 2018

You don't need one field for each field's timestamp. Just one field for all of them. You also don't have to manually add any code to the fields. This can all be done with a script that places the necessary code into the fields.

To detect when a field is changed, the best event is the Validate event, which is only called when a field's value is changed.  If you wanted to detect when a field is touched, meaning the user typed into a field, as opposed to actually changing the field, then you'd use

...

Votes

Translate

Translate
Community Expert ,
Jan 05, 2018 Jan 05, 2018

Copy link to clipboard

Copied

No, but you could very easily write a script to capture this data. You could store it as JSON in a hidden text field.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

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 ,
Jan 07, 2018 Jan 07, 2018

Copy link to clipboard

Copied

Thanks for the reply.  I was hoping to avoid the creation of 4,000 invisible text fields and the addition of the associated JavaScript to the visible fields, but c'est la vie.

Just out of curiosity, how does Acrobat know which fields have been changed since the last time a digital signature was applied?

So if I'm adding an action to a field that executes JavaScript, I want it to execute when the user either hits Enter or the field loses focus.  Is that equivalent to the Mouse Exit event?

Thanks,

[[ Frank ]]

Votes

Translate

Translate

Report

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
Adobe Employee ,
Jan 07, 2018 Jan 07, 2018

Copy link to clipboard

Copied

I looks at the low level changed objects. If you wanted to write a plugin in C/C++, you could do the same.

Votes

Translate

Translate

Report

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 ,
Jan 07, 2018 Jan 07, 2018

Copy link to clipboard

Copied

So the data is in there somewhere, just not trivially accessed.  I'm using the pypdf2 Python SDK to do post-processing on the files, so if I knew where in the object model I was looking I could do it that way.

Votes

Translate

Translate

Report

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 ,
Jan 07, 2018 Jan 07, 2018

Copy link to clipboard

Copied

(Along the way I figured On Blur was the event I wanted for this, assuming I go this route.)

Votes

Translate

Translate

Report

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 ,
Jan 07, 2018 Jan 07, 2018

Copy link to clipboard

Copied

You don't need one field for each field's timestamp. Just one field for all of them. You also don't have to manually add any code to the fields. This can all be done with a script that places the necessary code into the fields.

To detect when a field is changed, the best event is the Validate event, which is only called when a field's value is changed.  If you wanted to detect when a field is touched, meaning the user typed into a field, as opposed to actually changing the field, then you'd use the Keystroke event. The Blur event is fired when a field looses focus. This event could be fired when the user is just tabbing through the fields and does not intend to change it. All fields have these events, even if you can't enter code in them from the Acrobat UI.  But a script can put code in the these events for all fields.

As for digital signatures and the change info, whenever you save s PDF, Acrobat appends the changes to the end of the file.  So there is a record of all modifications going back to the first time the file was cleanly saved.  The modification time for the individual fields is not saved, but rather the last time the document is saved, is saved.  I'm not sure of the exact details, but I'm sure you can find out all about it in the PDF specification document and Acrobat's SDK guides. As Leonard said earlier, you'd need to write a plug-in or some other program much more sophisticated than Acrobat JavaScript to acquire this information. The Python SDK may be sufficient if it can drill down to the COS level. Be warned, it can be quite complex.

That said, you can certify a PDF with a digital signature, and allow form fields to be filled. I have not experimented with this process much, but the JavaScript model does provide a way to got all the changes since a document has been signed. However, I don't know if level of detail would match what you are looking for, or if form fields would even be reported if the certification is set to allow them.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

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 ,
Jan 15, 2018 Jan 15, 2018

Copy link to clipboard

Copied

Thanks for all the help.  I have it up and running as described - one big text field holding a JSON version of key/value pairs with field name/last modified time.  I haven't tested it when that field gets large yet, but I am optimistic that it will perform reasonably well.

Votes

Translate

Translate

Report

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
LEGEND ,
Jan 15, 2018 Jan 15, 2018

Copy link to clipboard

Copied

Just to confirm: the data is NOT there unless you yourself capture it.

Votes

Translate

Translate

Report

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 ,
Jan 16, 2018 Jan 16, 2018

Copy link to clipboard

Copied

That is correct, for non-signature data the only way I managed to do it is by capturing it myself using the Validate event on each field of interest and storing the time stamp.  Basically, here's the code I called (I wrapped it in a doc-level function) from each field's Validate event.

var dictionary = {}; // Initialize an object

var my_string;

var me = event.target.name; // Get the name of the current field

var current_time = (new Date()).toString().substring(0,32);  // Get the current date and time as a string

var hidden_field = this.getField("TimeStampData"); // Get the object for the field where we store our time stamp data

// Get the text out of the hidden field

my_string = hidden_field.value;

// Convert it to an object array

if (my_string != "") {

    dictionary = eval(my_string);

    }

dictionary[me] = current_time;

// Convert my dictionary back into JSON for storage in the hidden text field

my_string = dictionary.toSource();

// Put the data back into the hidden field

hidden_field.value = my_string;

Votes

Translate

Translate

Report

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 ,
Jan 15, 2018 Jan 15, 2018

Copy link to clipboard

Copied

You can improve performance by holding the data in a document variable until the form is closed, then convert to JSON and save in the field when the doc closes. Then on document open, converting the JSON to the doc variable.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

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 ,
Jan 16, 2018 Jan 16, 2018

Copy link to clipboard

Copied

Thanks Thom.  At the moment it's fast enough, but if I find it starting to crawl I'll give that a shot.

BTW, most of my work with Acrobat's SDK was long ago and all done externally using C, so having to do it all within the JavaScript engine in Acrobat is new to me.  Every time I googled something, like date processing or subtleties of scope or how to use the console in Acrobat, odds are your name came up as the author of the article.  So thanks for the advice you offered in this thread, and thanks even more for the decade or so of your advice that I mined to make it all work.

[[ Frank ]]

Votes

Translate

Translate

Report

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 ,
Jan 16, 2018 Jan 16, 2018

Copy link to clipboard

Copied

LATEST

You're Welcome

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

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