How to set a PDF to expire (Working Script)
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Adobe LiveCycle Policy Server provides this functionality in a server / client setup so that it authenticates the user, date and time against a trusted server before the form is opened.
Copy link to clipboard
Copied
http://www.adobe.com/products/livecycle/rightsmanagement/
It does not use scripting of any sort and so it cannot be so easily disabled as by removing a check from a preference setting or by changing the year on your clock to 2007 (since the script above does not have a start date to validate against either). It is embedded into the document and forces Acrobat or Reader to validate against your Rights Management server before you are allowed to open the document.
Copy link to clipboard
Copied
I totally understand that it is limited to 'keeping honest people honest' and has nearly zero "real" protection.
However, I have a request from an associate to protect pdfs by date and he wants it quick and cheap..... (we don't have tons of servers or want to acquire the know-how of maintaining them ourselves).
We've been trying the ADC, but have issues with it opening files on a Mac. Other solutions look nice (FileOpen, etc.), though they are a bit pricey-er than we'd like since the main thing is simply to have docs expire on a given date (we like the 'by user' features, but that's really not a huge requirement at this time).
Thanks for your input.
Copy link to clipboard
Copied
end user only has to turn off JavaScript to avoid it.
Aandi Inston
Copy link to clipboard
Copied
I clearly understand that and have tried to tell him, but 'pictures speak louder than words' and seeing it happen (or not) will likely help him understand everything.
What I have found (by studying the help files all weekend) is ONE way to implement this Java code (I'm not sure if it is 'right'...) that WORKS on ONE OUT OF SIX computers...
I placed the code on the Page Properties of the first page (steps below for the 'newbies' like me...) - it was really simple once I found out how to do it...
**** STEP BY STEP FOR OTHER NEWBIES ****
To use the Java script as described in this post (at least, as I did - maybe someone else will have better ideas and describe it for us...)
1. click on Pages on the left sidebar
2. right-click on the first page
3. select Page Properties, Action
4. under Select Action choose Run a Javascript
5. click Add
6. in the window that pops up, copy/paste the code from the post
7. click OK, OK to get back to the doc (change the Javascript later if you want, this is just 'initial testing'...)
8. IMPORTANT! Save the file under a different file name (or you may not be able to open it later!)
*********END OF STEP-BY-STEP*********
I included #8 because now, when I try to open the 'expired' doc in Acrobat, I get the 'expired' message and can't open it at all, but in IE, I see the document - on 5 of my 6 computers (including the one that Acrobat won't open!)
So, even though this is not 'secure' nor a 'pro' solution, please help me understand if a) I did this right and b) why it only works on the ONE computer (running Win 2000 Server and IE 6 with Reader 7) and not on any others (incluing NT, XP, Vista and 2000 Pro with various versions of IE and Reader).
Thank you for your time.
What I would really like to see is your reply with DETAILS on how to test this and both 1) learn how this stuff is done and 2) show my associate the difference in turning it 'on' and 'off'.
Best regards
Steve Majors
Copy link to clipboard
Copied
message in there about the problem.
Aandi Inston
Copy link to clipboard
Copied
Thanks. Sure wish I knew what that was, or where to find it....
guess it's back to the 'search the help file' again.....
I really do thank you (and all the experienced folks out there) for your tips/guidance, however, PLEASE remember that I got Adobe Acrobat last week (haven't even received the CD yet...) and I'm about as lost as anyone can get! (step-by-step is highly appreciated... - not only for me, but in reading the forums, it seems there are many more out there as bad, if not worse off than me!)
Steve
P.S. (added after doing some searching) I found that "Javascript console" is something that browsers have.... check out http://www.webmonkey.com/06/19/index3a.html for a nice page... They say, "In IE, go to Tools > Internet Options and choose the Advanced tab. Make sure the check box for "Display a notification for every script error" is checked. " I'm off to try that....
P.P.S. Turned that on, tried the 'expired' page and nothing special - was able to read the entire thing...
Copy link to clipboard
Copied
under Advanced > Document Processing. Not sure about other products.
Browsers have a different JavaScript environment to Acrobat; each one
may have a console, but when running Acrobat JavaScript you need the
AcrobatJavaScript console.
Please remember that you are now learning to be a programmer, and that
isn't something you can get good at in a day, a week, or a month; nor
through a handful of tips.
Aandi Inston
Copy link to clipboard
Copied
Hit Ctrl+J keys in your keyboard to open up the jscript console
Copy link to clipboard
Copied
When I turn on the JavaScript debugger in Acrobat Pro, I get this message (whether the 'clean' file or the 'expired' - same message).
Don't know if it has anything to do with the issue, but it is what it is...
Acrobat Database Connectivity Built-in Functions Version 8.0
Acrobat EScript Built-in Functions Version 8.0
Acrobat Annotations / Collaboration Built-in Functions Version 8.0
Acrobat Annotations / Collaboration Built-in Wizard Functions Version 8.0
Acrobat Multimedia Version 8.0
Acrobat SOAP 8.0
NotSupportedError: Not supported in this Acrobat configuration.
Doc.closeDoc:17:Page undefined:Open
As for being a 'programmer' - that ain't gonna happen.... I've been in computers since 1978 (Apple ][ days...) and found out a long time ago that I don't think like a programmer (it takes a special person with special skills and dedication, IMHO...), though I do like to 'hack around' and try out the simple stuff on my own.
What I'd really like to do/have/find is someone that totally understands this stuff as well as the business side of things that will stick to being 'on staff' (what we find is that "programmers" tend to get the majority of the project done, then something else comes along.... - certainly on the bigger projects.... we have a mostly-written back-end project done in perl, but now the programmer isn't answering the phone, or not getting into it to finish....
That's why I like to 'hack' - small changes are something I can do myself.
Anyway, I think this has gone as far as I want to go with it - something that 'kinda' works on one out of 6 computers seems to me to be a FAILURE, not an OPTION....
Thanks for your replies and the instructions on how to at least look at the debugger thing.
All the best.
Copy link to clipboard
Copied
>Doc.closeDoc:17:Page undefined:Open
Ok, if we refer to the JavaScript Reference there may be some clues
there. It's basically saying that closeDoc (which you'll find in the
code somewhere) isn't being allowed, usually for some security or
impracticality reason, rather than because you didn't ask right.
But no: no useful notes. It may be that you are trying to do this in a
browser document? You can't close the document window for a browser.
>
>As for being a 'programmer' - that ain't gonna happen....
It's already happened. You may feel you're just doing copy-and-paste
programming - but an increasing number of "programmers" actually
believe this is all there is to programming. I respect your judgement
that you don't want to be what you see a programmer as being, but you
are doing programming tasks, just as someone who has to saw a piece of
wood is doing carpentry tasks - and the saw is still sharp!
What I'm saying, I guess, is that trying to get this working while
simultaneously saying "No! I don't want to learn this stuff" isn't
going to work.
Aandi Inston
Copy link to clipboard
Copied
Just another reason why "JavaScript-based Document Security" is a misnomer and why this script really shouldn't be used for any sort of security - all you have to do is open the document in a browser to bypass the security.
Copy link to clipboard
Copied
Is there a specification I am missing... a file type.. or reason my PDF won't allow me to edit such things.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Does anyone know if there is there a way to generate silimar results in designer? (an expiration by date, or number of times opened etc...)
Copy link to clipboard
Copied
Turning off JavaScript or changing the date on your computer will circumvent any form of "security" this script may seem to provide.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
EDIT: Sorry, it's been renamed Adobe LiveCycle Rights Management for the LiveCycle ES Suite.
Copy link to clipboard
Copied
1) Is there a way to add this bit of JavaScript information to a pdf file in a batch fashion via Java, Python, etc.? I would like to add this to a build process in Ant. Any suggestions?
2) The responses regarding how insecure this is and to use the client/server approach seems worthless for a situation where the pdfs may never see internet connectivity. The only reason for using pdfs is for mobile users of my information. That is first and foremost why I need some document-embedded solution. Are there any document-embedded solutions that are known that do not involve client/server communication?
Thanks a lot for any assistance.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
There is no perfect solution for expiring a PDF in a non-internet-connected scenario. If you can't control the timechecking in a known-safe server environment and have to rely on information from the local system, your security it lost since anybody can do anything to the local system. If you're looking for something showy that will make people feel warm and think that you have some form of security on your documents, use the above script. But I would be weary about passing it off, especially in a professional environment, as "secure". Anybody who wants to spend 5 minutes on Google looking at PDF security will realize your "security" is a complete sham and that could reflect badly on you.
The best option to secure a PDF in a non-connected environment is to apply document encryption and only give the password to those who need to view the document.
Oh and LiveCycle Rights Management ES has plenty of fallback configuration options for how to handle non-connected environments with policy-protected PDFs.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
function CheckExpiration(LastYear, LastMonth, LastDate, LastHour, LastMin, LastSec, LastMS) {
// document level function to see if passed date less than today's date
// check that numbers are passed as parameters
if (isNaN(LastYear) ) LastYear = 1900;
if (isNaN(LastMonth) ) LastMonth = 1;
if (isNaN(LastDate) ) LastDate = 1;
if (isNaN(LastHour) ) LastHour = 0;
if (isNaN(LastMin) ) LastMin = 0;
if (isNaN(LastSec) ) LastSec= 0;
if (isNaN(LastMS) ) LastMS = 0;
LastMonth = LastMonth - 1; // adjust the passed month to the zero based month
// make the expiration date time object a numeric value
var myDate = new Date( Number(LastYear), Number(LastMonth), Number(LastDate), Number(LastHour), Number(LastMin), Number(LastSec), Number(LastMS) ).valueOf(); // convert passed expiration date time to a date time object value
// get the current date time's object as a numeric value
var today = new Date().valueOf();
// return logical value of the comparison of the passed expiration date value to today - if true document has expired
return (myDate < today);
}
// the following code has to be executed after the above function is defined
// edit following fields
var ExpireYear = 2008; // 2008
var ExpireMonth = 3; // March
var ExpireDate = 21; // 21st
var ExpireHour = 12; // noon
var ExpireMin = 0;
// the following code has to executed after the above function and variables are defined.
// test for expired document based on result of the passed time elements compared to the current date and time as returned by the CheckExpiration() function.
if (CheckExpiration(ExireYear, ExpireMonth, ExoireDate, ExpireHour, ExpireMin) ) {
this.closeDoc(1);
app.alert("This files has expired.",1,0,"Expired");
}
Copy link to clipboard
Copied
-
- 1
- 2