What you are asking for is more complex than just setting the current date. Each time the form prints it has to know that it has to change the date. I would suggest doing this.
First, setup a document level script to set the date to the current date. I suspect that you have already done this?
Next, Create a "DidPrint" document action to increment the date. To do this the script will need to scan the current text value of the date, add one day to it, and then reformat it. You'll find information on this type of scripting in these articles:
Since the increment happenes in the Did Print you will need to print each copy individually. If you enter 10 copies in the print dialog it won't work. You have to print one at a time. You can automate this activity with a console script.
One of the advantages of incrementing in the DidPrint is that you can also manually enter a date and it will increment from there.
The source for PDF Scripting Info
Having trouble, Why Doesn't my Script Work?
Thanks for the info.
Due to restrictions on the computer the consule script won't be possible. I think the best way to do it would be to have one page (first page) where you set the date/auto sets for today and x (15-30) additional pages where each page has a different date field and has a java script code that takes the date from the first page and adds 1 day to that and so on till the end of the document.
George also points out an excellent solution, put the script in a (non-printable) button on the document itself. However, due to security restrictions this solution can be a bit awkward, but no more so than using the Console window. Each solution takes a little extra effort.
The problem with haveing multiple pages is that you need to manually create a document with all the pages already in it. This is certainly a doable solution, It just limits you to the number of pages you've already created manually. At least for an AcroForm Solution. If you recreate your form as a Dynamic LiveCycle, then creating new pages on the fly is not an issue.
Any of these solutions will work just fine, the real trick is to increment the date.
Here's a short script that starts with todays date and adds one day for each iteration of the loop and then prints
// One day in milliseconds
var nOneDay = 24 * 60 * 60 * 1000;
var nToday = (new Date()).getTime();
oTheDate = new Date(nToday + i*nOneDay);
// Format Date
cTheDate = util.printd("mm/dd/yyyy",oTheDate);
this.getField("MyDate").value = cTheDate;
This same loop could be used to fill in fields on a multi- (repeated) page form.
Using the util.scand() function, this loop could be setup to start at any arbitrary date.
Yes I did misunderstand your first post, based on what you said there should be no problem as soon as I get more time to mess with the file I'll get back to you (however they are working me to death so it might be a few days)
lol thanks for the help
also will the code take into account different months like if I do the print on 6/30, will it know when to do 7/1
The date calculation is done with milliseconds since 1970, then formatted as date text. Quanties such as day and month are not used, it is the formatting that determines the year, month, and day.
Now if you enter something like 6/30, it is the date parser that determines how the numbers are interpreted, the "util.scand()" function. And I believe it will read bad dates like this correctly. But you'll need to test it out.
Thanks for the additional info, and I had enough time to try it out.
The code you gave works and I added a button to print instead of it instantly poping up on open. So basically I just have to set my printer settings (certain paper tray / hole punching) and spam click print as it pops up 15 times or if I change it to 30, 30 times?
There is no code that can be within the pdf file, that will auto accept all the print promts after the first one? Spam clicking print is good enough but having code to do it itself would be much better.
The problem with automating print in a document is that it is a privileged operation. Which is why you get the popups, and why I suggested running the code from the console window. The console window is privileged. However, I believe that if you list the document as "trusted" in the Enhanced Security privileges pane in the Acrobat Preferences, that Acrobat will allow silent printing from a script in that document.