Posted: 2/18/2015 11:59:10 PM EDT
|
I posted this in Urban Commandos but there is much more traffic here.
I want to add JS to a PDF file that I have created. The point of the JS is too subtract 16 days from the input date. aka Start date 15 May 15 Suspense date 29 April 15 Anyone? I dont know a thing about JS. Thanks! |
|
I've never buried Javascript in a PDF, so I don't know what the input and output services look like. In basic terms, all you need to do is to get the input date into a variable, date.parse it to get milliseconds since midnight, subtract an offset and output back in the proper locale format. Do you know anything about the mechanics of putting Javascript into the PDF? In HTML, this code provides a demo of calculating a negative 16 day offset: <!DOCTYPE html> <html> <head> <script language="JavaScript"> inputstr = "02/17/2015"; nd = new Date(Date.parse(inputstr) - 1380000000); document.write(nd.toLocaleString()); </script> </head> <body> </body> </html> |
|
Quoted: I posted this in Urban Commandos but there is much more traffic here. I want to add JS to a PDF file that I have created. The point of the JS is too subtract 16 days from the input date. aka Start date 15 May 15 Suspense date 29 April 15 Anyone? I dont know a thing about JS. Thanks! This is probably the document that you seek: http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/js_api_reference.pdf What you are probably looking for (because I'm not going to read the whole document) is an event of some kind that would provide a suitable trigger - so some variation of "onLoad" or "onReady" or something along those lines. It wouldn't be suitable for document level scripting as it could potentially run before the page has finished loading, so it would try to add text to a field that isn't available yet. Once you've found your event, you should probably be able to attach an action to that event. That action will involve your bit of javascript. I'm mostly guessing here because... well, because I'm not going to read the whole document and I've never actually tried to use JS in a PDF. I believe one issue might be whether the PDF reader being used will support javascript. The most current Adobe Reader is pretty much guaranteed to do it, but if people are using older versions or a browser-based reader, who knows? Edited to add: OK, it turns out that "reading the post" really should come before "writing a reply" It looks like you should be able to check for event.commit on the input field, and when the commit is made, grab the input, run your magic script, and then send to the second field. So, start from event.commit and work your way forward from there.Possibly. |
|
Quoted:
I wouldn't even bother, since most JS in pdf files is disabled and never enabled by the user anyway, for the simple fact that it's a major gaping security hole. THIS. There is no fucking way I'd allow that, especially if I was using something as perpetually broken as Adobe Reader. |
|
Quoted:
This is for an internal .mil document for my unit. Its a routing slip for actions. Quoted:
Quoted:
I wouldn't even bother, since most JS in pdf files is disabled and never enabled by the user anyway, for the simple fact that it's a major gaping security hole. This is for an internal .mil document for my unit. Its a routing slip for actions. An even better reason not to do it. |
|
Quoted:
An even better reason not to do it. Quoted:
Quoted:
Quoted:
I wouldn't even bother, since most JS in pdf files is disabled and never enabled by the user anyway, for the simple fact that it's a major gaping security hole. This is for an internal .mil document for my unit. Its a routing slip for actions. An even better reason not to do it. I gave up on this. Thanks for the help to everyone though. |
|
Quoted: I gave up on this. Thanks for the help to everyone though. Quoted: Quoted: Quoted: Quoted: I wouldn't even bother, since most JS in pdf files is disabled and never enabled by the user anyway, for the simple fact that it's a major gaping security hole. This is for an internal .mil document for my unit. Its a routing slip for actions. An even better reason not to do it. I gave up on this. Thanks for the help to everyone though. Do it in Excel and save to PDF. |
It looks like you should be able to check for event.commit on the input field, and when the commit is made, grab the input, run your magic script, and then send to the second field. So, start from event.commit and work your way forward from there.