These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Coupon Javascript?

vegasphotog
Registered: Oct 22 2008
Posts: 6
Answered

My apologies in advance...I have tried to use my help window and search this forum....

I am trying to create a page with multiple coupons that have perpetuating expiration dates....Like in 14 days, etc.

I created one a year ago but cannot figure out how I did it.

Just to be clear...this is for a website so when someone opens the pdf today, it expires in 14 days and if they opened it tomorrow it would expire 14 days from tomorrow.

Thanks in advance.

I am working in CS4 Suite with LiveCycle and Acrobat Pro.

My Product Information:
LiveCycle Designer, Windows
UVSAR
Expert
Registered: Oct 29 2008
Posts: 1357
You [i]could[/i] use Javascript to populate various text fields on the PDF using the good old date() object, but if you want the coupons to be in any way secured, it's not an option - if Javascript can update a form field, the user can update it too - and if they've turned Javascript off the dates won't show at all.

If you're serving the PDFs from a website, I'd design the coupons with blank spaces for the dates, and use a server-side PDF engine (such as the free FPDI_protection PHP class) to write on the extra text, secure the PDF and push it to the client - so they don't have anything forms-related they can fiddle with.
vegasphotog
Registered: Oct 22 2008
Posts: 6
Thanks for your reply.....I would have no idea how to do the second thing you recommended...but, this is a very unsophisticated application and security is not an issue.....I will try and dissect your primary comment.
vegasphotog
Registered: Oct 22 2008
Posts: 6
I guess Ifigured it out...

I needed to show the Window/Script Editor and pull down calculate and put in the following vallue:

var oExpire = new Date(new Date().valueOf() + (14 * 24 * 60 * 60 * 1000)); // today's date plus 2 days in milliseconds
$.formattedValue = util.printd("MMM DD, YYYY", oExpire, true); // formatted expiration date

The first set of numbers; in this case 14 are when the coupon expires.

The field obviously has to be a date time field and the value type must be calculated -Read Only.