javascript - JScript for PDF to enter the current date regardless if text-field is full or empty -


I have a small problem with a PDF document. I have a text field called "date", and in this I If I execute the JScript code:

  if (event.value == "") {event.value = util.printd ("Dd.mm.yyyy", New Date ())} (Event.value! = "") {Event.value = util.printd ("dd.mm.yyyy", New Date ())}   

Now, it works fine on itself Does it, but it does not work as well as I want.

Say, if I opened the document on 01.07 .2014, then the date will be 01.07.2014, then I saved the document, and that was it.

Now I open the document on 20.07.2014, the date is still 01.07.2014. I have to reduce at least 1 character of JScript to do my job

What am I missing?

The problem is that for your scenario, using field events is not the best way (as you have seen).

When you want the field to display the document when you have opened the document, you will use the pageon event (in Acrobat XI, it is well hidden: open the thumbnail panel, the related page's Select, open the page properties, and switch to the Action tab via the contextual context menu).

The easiest way is to add this code to the Open page script:

  this.getField ("MyOpeningDateField"). Value = util.printd ("dd.mm.yyyy", new date ());   

This works well with a single page document, but if you have multiple pages, then you will run even when you visit that page.

1) You create a document-level script, which contains only this line:

  var loaded = 0;   

2) You can modify the Open Page code as follows:

  if (loaded == 0) {this.getField ("myOpeningDateField") . Value = Util.printd ("dd.mm.yyyy", new date ()); Load ++; }   

and should do so.

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -