Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 225
  • Last Modified:

500 pts. Making text field show 2 weeks ahead of current date

Hello,

I have a text field in an acrobat 6 file called "today" and I want it to show 2 weeks ahead of the current date in MM/DD/YYYY format. Below is a solution given to me by khkremer. Can anyone add to this answer or give me another solution?

-----------------------------------------------------------
select the Form tool: "Tools>Advanced Editing>Forms>Text Field Tool" and draw a rectangle on your PDF document. This will bring up the preference dialog for this form field. Select the "General" Tab and specify "Today" as the field name. Look around on the UI, select all the tabs, but you don't need to make any more changes here. Close the dialog. Select "Advanced>JavaScript>Document JavaScript". Give the script a name (e.g. "OnOpen") and click on the "Add" button. Replace the complete function stub with this line:

this.getField("Today").value = "today's date";

Save the file, close it and reopen it. YOu will now have the string "today's date" in your field. This information plus the first link that I provided should get you started with adding date information to your documents. You can have multiple fields with the same name. This will then add the date to all of these in one operation.
-------------------------------------------------------------
Here is the link khkremer  made reference to, though I cannot make heads or tails of it.
http://www.experts-exchange.com/Web/Graphics/Adobe_Acrobat/Q_21003596.html

Your help on this is greatly apprieciated!

coma12
0
coma12
Asked:
coma12
  • 2
  • 2
1 Solution
 
coma12Author Commented:
Here is a link to the pdf that I want to add the 2 weeks from current date text field to. The date is manually added right now, every day - ugggh.
http://www.reedh.com/newsletter/NewsletterOrderForm050427.pdf

Also if I will need to make the date in red.

thanks,

coma12
0
 
Karl Heinz KremerCommented:
Were you able to add the text field to the document as I suggested in your earlier question?
0
 
Karl Heinz KremerCommented:
Instead of the simple assignment from my sample, use this JavaScript instead:

var dateField = this.getField("Text1");  // <-- Replace this with the field name for your date field
var today = new Date();

var newDateValue = today.valueOf();   // converts today to a number that we can calculate with

newDateValue += (14 * 1000 * 60 * 60 * 24);  // add 14 days
                                      // 1000 miliseconds times 60 seconds times 60 minutes
                                      // times 24 hours times 14
var adjustedDate = new Date(newDateValue);  // create a new date based on the newDateValue variable
dateField.value = util.printd("mm/dd/yyyy", adjustedDate);       // format and assign the new date

0
 
coma12Author Commented:
khkremer,

Thank you so much!!!

I was hoping you were scanning the acrobat section.

Once again you came through like a champ and saved the day!

coma12
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now