Mrrrr's Forum (VIEW ONLY)
Un forum care ofera solutii pentru unele probleme legate in general de PC. Pe langa solutii, aici puteti gasi si alte lucruri interesante // A forum that offers solutions to some PC related issues. Besides these, here you can find more interesting stuff.
Lista Forumurilor Pe Tematici
Mrrrr's Forum (VIEW ONLY) | Reguli | Inregistrare | Login

POZE MRRRR'S FORUM (VIEW ONLY)

Nu sunteti logat.
Nou pe simpatie:
beatrice17
Femeie
24 ani
Bucuresti
cauta Barbat
24 - 80 ani
Mrrrr's Forum (VIEW ONLY) / Tutoriale si Ghiduri Utile // Tutorials and useful guides / [PDF] Insert Today in Date Field / Insert Now in Field [JavaScript] Moderat de TRaP, TonyTzu
Autor
Mesaj Pagini: 1
TRaP
Moderator

Inregistrat: acum 6 ani
Postari: 787
Assuming you have a PDF with fields created for various things, including date fields.

To make the script change the date when opening the PDF, do this:

1. Open the desired document and get the desired field name, just as above

2. Go to FILE - DOCUMENT PROPERTIES

3. Select INITIAL VIEW

4. Under OPEN ACTION, select Action Type: CUSTOM, Action: ...

5. Click ADD - RUN A JAVASCRIPT

6. Add the following script replacing "Data" and "īn data" with your fields names:

// get new Date object
var d = new Date();

// format to dd/mm/yyyy
var sDate = util.printd("dd.mm.yyyy", d);

// insert date into form field
this.getField("Data").value = sDate;

// insert date into form field
this.getField("īn data").value = sDate;


7. Click OK and OK, then SAVE the PDF file.

8. When opening it you will have the fields containing the date of today. If you want to keep the PDF with empty fields, just delete the dates and save again - fields will be empty but when opening they will again be completed automatically.

Source:

OPTIONAL

If you also want to insert current time in a field, after the code above insert the following code (change the colored field name with your own):

// add time to another field
var t = d.getTime();
var sTime = util.printd("HH:MM", new Date(t));
this.getField("īncepānd cu ora").value = sTime;


If you want to add a time from eg. 15 minutes ago, replace the following line:
var t = d.getTime();
with:
var t = d.getTime() - 15 * 60 * 1000; // - 15 min * 60 s * 1000 ms

Source:


pus acum 4 ani
   
TRaP
Moderator

Inregistrat: acum 6 ani
Postari: 787
In PDF-XChange Editor Free version you can add Javascript snippets to run on your fields and bookmark clicks.

So instead of the option above, do either of these 2 options:

Option 1 - change date to today only after clicking the field with the date

1. Open the PDF in PDF-XChange Editor Free.

2. Go to the FORM tab and click on FIELDS button.

3. In the list of fields find your desired date field and remember it's name (in my case it is "Data")

4. Go to the HOME tab and click on CREATE LINK.

5. Insert a rectangle over the date field you found at no. 3.

6. In the DIALOG BOX that appears, click on the ADVANCED button.

7. Select RUN A JAVASCRIPT.

8. Type in the following script, replacing "Data" with your field name:

// get new Date object
var d = new Date();

// format to dd/mm/yyyy
var sDate = util.printd("dd.mm.yyyy", d);

// insert date into form field
this.getField("Data").value = sDate;


9. Click OK then OK again.

10. Exit the CREATE LINK tool by clicking on the HAND tool.

11. Click on the place where you created the rectangle to run the script and display the date.

Option 2 - change the date to today when saving / before saving / when closing / after printing / before printing the PDF fie

1. Open the PDF in PDF-XChange Editor Free.

2. Go to the FORM tab and click on FIELDS button.

3. In the list of fields find your desired date field and remember it's name (in my case it is "Data").

4. Also in the FORM tab click on the DOCUMENT ACTIONS.

5. Select BEFORE DOCUMENT SAVING / AFTER DOCUMENT SAVING / BEFORE DOCUMENT CLOSE and click the EDIT button, then insert the following script replacing "Data" with your field name::

// get new Date object
var d = new Date();

// format to dd/mm/yyyy
var sDate = util.printd("dd.mm.yyyy", d);

// insert date into form field
this.getField("Data").value = sDate;


6. Click OK and Save your document. The date of today should appear in your field.

Source:


pus acum 4 ani
   
TRaP
Moderator

Inregistrat: acum 6 ani
Postari: 787
UPDATED post #1 & topic title with time field

pus acum 4 ani
   
Pagini: 1  

Mergi la