Close File 24 hours After Opening

(Not having experience with pdf java script), I've been trying for 5 or 6 weeks to write a script - to be placed in Document Scripts (I'd prefer to say away from form fields) - that keeps a file open 24 hours after it's first launched––and then closes. (It's a 24 hour trial version).
I've tried different configurations. (This following script works but doesn't serve my goal: Reason is, in the script below, the "final date" is fixed. The final date  has to be calculated as 24 hours (1440 * 60 * 1000) after the initial launch date.):
var curDate = new Date();
var finalDate = new Date("8/08/2011");
if(finalDate.getTime() < curDate.getTime())
{this.closeDoc(true);}
I've tried using the following as the launch date but I can't make it work:
var f = this.getField("Today");
f.value = util.printd("mm/dd/yy", new Date());
The user is free to open and close the file during the 24 hours: So: I'm also concerned that the initial "curDate" remain stable. If it doesn't, I must change that part of the script as well and use a "Date the file was opened" as a variable. I've triend to use calcluations - but have not been able to succeed. At least, I figured out, there are 3 variables: the open-file-date, the 24 hours after open file date, and current date. In the end, I check to see if the 24-hours-after-open file is < than current date and if so, closeDoc. At least I learned that much.
Can anyone help me? I bet it's simpler than what I'm making it out to be, but I'm burnt to a crisp - I've spend all my time on this and have come to realize, it's  above my skill level and could use some help..... thank you in advance
Clint

You should be aware that even if you get the code right, this method can easily be disabled simply by the user disabling JavaScript, or using a non-Adobe PDF viewer.
The main difficulty seems to be that you are not recording and storing the initial opening date/time. You will have to store this date somewhere, either in the document or in a global variable. The problem with storing it in the document is the modified document would have to be saved by the user, which may not happen. So that leaves using a global variable.
Your code could first check for the existence of the global variable that you set up for this, and if it doesn't exists, create it, set its value to the current date/time, and set it to be persistent. You do this with the global.setPersistent method: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.778.html
Read up on the other information on the global object in the documentation.
You then just need to compare the current date to this stored date whenever the document is opened. If the difference exceeds 24 hours, oyu cna close the document using the doc.closeDoc method: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.448.html
Here's a little information on date arithmetic: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_Dev_AcrobatForms.76.35.ht ml
And you should be able to find more with a search.
Again, this can't be considered secure or robust, but it may be sufficient for your needs.

Similar Messages

  • I am running windows 7 on a dell desktop. PDF files freeze shortly after opening or tryiong to print. Only the PDF freezes all other functions remain normal. I can close the PDF. I have an HP officejet pro 8600

    I am running Windows 7 on a Dell desktop. PDF files freeze shortly after opening. No other programs freeze. I can close the PDF file. I am using a HP Officejet Pro 8600

    Hi Duncan,
    Please confirm if you Are using Acrobat.com online services or Acrobat software?
    Regards,
    Rahul

  • Double-clicking to open files stops working after opening lots of files.

    When I double-click a file it will open the file in CS6 version 13.0.1, but then after a while double-clicking will no longer open jpeg or raw files.  I can open the same files by going to File > Open in the Menu Bar.
    When I am simply opening downloaded files from my camera, I can open 200-300 by double-clicking with no problems.  However, at times when I am working on an image, it is not long before I can't open a file by double-clicking.  It will open a blank Photoshop window, but without any Toolbar or Menu Bars.
    This happens on a regular basis.  Sometimes, also, Photoshop is slow to Quit, for no apparent reason.
    Is anyone aware of this problem?

    Still having this problem.
    If I open a jpeg and just change the name, then Save As to a folder, I can then open another jpeg by double-clicking.
    However, whenever I open a jpeg and make changes to the image in Photoshop, then Save As to a folder, I can then no longer open a jpeg by double-clicking.  Photoshop will open, but the jpeg will not open.
    Since this only happens after making changes to a jpeg in Photoshop, it seems to me the problem is with something in Photoshop, and has nothing to do with my OS.

  • Can't find an excel file I saved after opening it/saving it from yahoo.email

    I was sent an excel spreadsheet via my yahoo email
    I opened it and then saved it, since it did not allow me to fill in the blanks until I saved it. I cannot find it anywhere, and now cannot even find my location for "Temporary" files on my laptop, either, which is where I think it may have gone.
    I do not have the info anymore to fill this requested form out again. PLEASE HELP!

    You should always save a file that you open via internet under a different name.<br />
    Firefox usually saves such a file as read-only anyway, so you can't edit and save the file.<br />
    It is not guaranteed that you files persist after closing the application that opens them via an open with dialog.<br />
    So in your case you may have lost the file.<br />
    You can check in Excel if there are possible temp files created to save the data while editing.

  • [SOLVED] xterm Closes a Few Seconds After Opening

    Using awesome, no DE. As in the title, xterm closes itself about 4 seconds after I open it with no errors displayed. I don't even know how to begin to figure out what's going wrong.
    Any ideas?
    Last edited by silverhammermba (2012-11-23 19:06:18)

    How do you launch it?  What's in your .bashrc?  Do errors show up in the xlog or on the tty you launched X from?  Do other terminals do the same thing?  If no to the last question, what happens when you launch xterm from a working terminal emulator?

  • Metro Photos app close by itself immediately after opened

    W10 Pro technical preview build 10041
    When I open the photos app from the metro it close by itself immediately, no chance to see the pictures.
    Also I can´t uninstall the app. 
    After right click options available are pin to start and pin to taskbar.

    I am also having the same exact problem...

  • Dng files not working after opening it once

    I have a Parrot Bebop drone and took photos in the DNG format. I can open the DNG images only once. It opens in Photoshop RAW, I change some settings and crop the image. Once I press the "Done" button, I can no longer open the DNG file and Photoshop just says the file format is not supported!?!?!?

    If you can give us the Camera model, DNG converter version Camera Raw version and other information, it will help us chase it down.
    As a starter, be sure Photoshop and Camera Raw are updated.
    Also look at the list below:
    Adobe product and version number
    Operating system and version number
    The full text of any error message(s)
    What you were doing when the problem occurred
    Screenshots of the problem
    Computer hardware, such as CPU; GPU; amount of RAM; etc.

  • Under regular user account Firefox closes its windown right after opening it, but this does not occur when run from administrator account.

    I don't have the problem on Vista or XP. I have no problems when I am logged on as administrator. When logged on as a regular user some or all of the Firefox windows will open and then immediately close. It does not help to run as administrator or set other compatability options. I also see this on Thunderbird. I have not seen this problem on any of my other software.

    I don't have the problem on Vista or XP. I have no problems when I am logged on as administrator. When logged on as a regular user some or all of the Firefox windows will open and then immediately close. It does not help to run as administrator or set other compatability options. I also see this on Thunderbird. I have not seen this problem on any of my other software.

  • Raw files look different after opening them in CC

    HI,
    I open them in ACR to edit the raw files for white balance and what not, once I get them perfect I click open image to send them to photo shop CC the image is drastically different.  Please help and I doing something wrong?  it worked great in CS5.
    `Terry

    You have a broken display profile. The conversion from source profile to display profile should end up with the same result in each, but since the source is different it can happen that one app chokes and the other not.
    The choice of working space in Photoshop has no bearing on this, unless you've done something silly like setting Photoshop's color management to "off". Whatever profile comes out of ACR should be honored by Photoshop. They do not have to be the same.
    Recalibrate, or if you don't have a calibrator set sRGB IEC61966-2.1 as default display profile in Windows color management. Relaunch Photoshop so that it can pick up the new profile at startup.

  • Firefox closes a document after opened. Hard to read news articles on some sites. Getting very tired of article closing one paragraph into it.

    Firefox continues to close documents after opened on some sites. News articles opened will close after opened. Very upsetting to have to switch to another browser just to read an article. It also closes down Amazon.com after opened. It is not just one URL. Cache has been cleared, spy ware cleaned, and no viruses. Very frustrating.
    == URL of affected sites ==
    http://

    Among the alternatives not mentioned... Using a TiVo DVR, rather than the X1; a Roamio Plus or Pro would solve both the concern over the quality of the DVR, as well as providing the MoCA bridge capability the poster so desperately wanted the X1 DVR to provide. (Although the TiVo's support only MoCA 1.1.) Just get a third-party MoCA adapter for the distant location. Why the hang-up on having a device provided by Comcast? This seems especially ironic given the opinions expressed regarding payments over time to Comcast. If a MoCA 2.0 bridge was the requirement, they don't exist outside providers. So couldn't the poster have simply requested a replacement XB3 from the local office and configured it down to only providing MoCA bridging -- and perhaps as a wireless access point? Comcast would bill him the monthly rate for the extra device, but such is the state of MoCA 2.0. Much of the OP sounds like frustration over devices providing capabilities the poster *thinks* they should have.

  • Apps close right after opening - IOS 5

    Just upgraded my ipad 2 to ios 5. Some apps that worked fine before upgrading ios, now close a few seconds after opening them. Any clues on how to solve this? (already tried reboot, delete app and re-install... doesn't work)

    I was under the impression that any apps that you currently had on your iPad would work with the new updated iOS. However, I can't remember why I even think that but I probably read here on this site.
    In any event, I believe the overwhelming majority of your apps should still work even if some will not under the new iOS. What I'm saying is that there may be something else going on that will require something additional on your part - perhaps restoring your device to factory settings and then restore to your backup.
    iBooks is an Apple App but there are other reasons why the apps could be crashing. You could try closing all of the apps in the recents tray and restart and see if that helps, but you may need to restore your device(s) if nothing else works.
    Go to the home screen first by tapping the home button. Quit/close open apps by double tapping the home button and the task bar will appear with all of you recent/open apps displayed at the bottom. Tap and hold down on any app icon until it begins to wiggle. Tap the minus sign in the upper left corner to close the apps. Restart the iPad. Restart the iPad by holding down on the sleep button until the red slider appears and then slide to shut off. To power up hold the sleep button until the Apple logo appears and let go of the button.

  • InDesign won't close files

    Hallo everybody,
    I'm new her at InDesign-Scripting-Forum, but I have a great problem, and hope there is somebody out who can help me:
    My problem is that InDesign won't close files which have been opened.
    Just a little Javascript (I have reduced it to the minimum):
    var myFile="1.indd";
    // Open the file
    var myDoc=app.open(File(myFile));
    // Close the file
    myDoc.close(SaveOptions.no);
    if(app.documents.length > 0)
            alert("Still " + app.documents.length + " files opened");
    If this script starts from InDesign Javascript Panel, there are no problems or errors.
    InDesign will open the file (1.indd), and closes the file, and no alert will appear.
    But.... if the Javascript ist copied to the InDesign "startup script" folder, so that InDesign should
    run this script on InDesign Startup,the alert will appear.
    If you are running the script in a loop, just like working with 10 files of a current directory,
    InDesign will show alert of 10 opened files at the end.
    So.. at the end of the script, I want to move the (opened and closed) file to another directory.
    But when InDesign "says" the file is opened, I cannot move or rename the file.
    (It is only possible when running the script manually by the Javascript Panel).
    Can anybody help me, so that I can close the file, or that InDesign will close the file
    when running as a "startup-script"?
    Thanks very much.
    Martin.

    I have 8 MB of RAM. I restarted all the software, but not my computer.
    It is in the left column that I am having the problem.
    There was a previous discussion thread where a user on Mountain Lion was having the same issue, but it wasn't resolved in that discussion thread either.

  • I have acrobat standard and it will not allow me to edit.. every file i go to open it says "there is a active file open and must close in acrobat" other times it says account cannot be validated after I have already paid for it.. please advise

    i have acrobat standard and it will not allow me to edit.. every file i go to open it says "there is a active file open and must close in acrobat" other times it says account cannot be validated after I have already paid for it.. please advise

    Hi Timothy,
    The account cannot be validated error was due to a glitch on our activation server that has been fixed now.
    Please try using acrobat now and check if you are still facing the problem.
    Regards,
    Rave

  • I'm using acrobat pro in my project after debuging the project and after opening a certain number of PDF files I receive the message: the maximum number of files opened has been reached, you have to close some files to continu.even doing that, I steel rec

    I'm using acrobat pro in my project after debuging the project and after opening a certain number of PDF files I receive the message: the maximum number of files opened has been reached, you have to close some files to continu.even doing that, I steel receive the same message.Some one can tel what to do please? Thanks

    Hi Memalyn
    Essentially, the bare issue is that you have a 500GB hard drive with only 10GB free. That is not sufficient to run the system properly. The two options you have are to move/remove files to another location, or to install a larger hard drive (eg 2TB). Drive space has nothing to do with SMC firmware, and usually large media files are to blame.
    My first recommendation is this: download and run the free OmniDiskSweeper. This will identify the exact size of all your folders - you can drill down into the subfolders and figure out where your largest culprits are. For example, you might find that your Pictures folder contains both an iPhoto Library and copies that you've brought in from a camera but are outside the iPhoto Library structure. Or perhaps you have a lot of purchased video content in iTunes.
    If you find files that you KNOW you do not need, you can delete them. Don't delete them just because you have a backup, since if the backup fails, you will lose all your copies.
    Don't worry about "cleaners" for now - they don't save much space and can actually cause problems. Deal with the large file situation first and see how you get on.
    Let us know what you find out, and if you manage to get your space back.
    Matt

  • How do I put a "close file" icon in the toolbar? I've searched for an hour to find the answer with no luck?

    How do I put a "close file" icon in the toolbar? There's an "open file" icon by default, but I cannot -- in spite of searching for an hour--find a way to put a "close file" icon in there?

    Toolbar where? What program? What system?
    Mylenium

Maybe you are looking for

  • When trying to update, I get the message: Account not in this store,...switch to the Canadian store.  How do I do that?

    When trying to update apps, I get the message:  "Account not in this store,...switch to the Canadian store before purchasing"  How to I switch, and how did it even get changed to US store?  I don't remember changing anything, and I used to be able to

  • How to open Applications using Plugins

    How do I select a plugin to open an Application in the Applications options menu? For example I want MPEG movies to open with a plugin such as Quicktime Plugin or Windows Media Plugin or DivX WebPlayer Plugin instead of using an external media player

  • Unable to find Idoc in XI

    Hi, Idoc -> XI -> File I am trying to send an Idoc (ZANSO_MT) from R/3 side to XI. Status of the message is green in we05 in R/3 but I am unable to find it in XI. I have checked in idx5, we05. All the RFC connections are working fine with authorizati

  • Need pattern to display negative value in red

    I am having one xdp form which contains multiples objects having some textfields mapped with some xsd. requirement is if values is negative need to display it in red color as  "-$18,970.50" currently it is getting displayed as   "$-18,970.50" I have

  • Can i get a new ipod touch battery for free?

    My battery life is horrible and i dont know why... i let it die and charge everynight....... i hope that makes sense to you. Is there a way i could figure out if my ipod is being defectiveor not..thanks.