Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

A New Career Decision

Options
2»

Comments

  • Registered Users Posts: 397 ✭✭The Red


    Actually Ive used codacademy to learn some HTML and Css and I found it extremely rewarding, the issue for me was that I was doing it in my spare time (very little time, full time job and 2 baby girls) and it was hard to continue when I wasnt implementing the stuff I learned on a daily basis.

    So I guess I know a little bit of what its like to code... I like it quite a bit.

    Would this be a good indication of what would be in store with the likes of Java?


  • Registered Users Posts: 397 ✭✭The Red


    Also, does anyone here know of a good thread to ask someone about a Javascript I cant get to work?

    Thanks.


  • Registered Users Posts: 627 ✭✭✭House of Blaze


    The Red wrote: »
    Also, does anyone here know of a good thread to ask someone about a Javascript I cant get to work?

    Thanks.

    What's the issue?

    I'll help if i can! Put your code in code tags when you post to make it appear properly.


  • Registered Users Posts: 397 ✭✭The Red


    Ok so, as I said, I am new to this stuff and I got this code somewhere to basically make a set of boxes appear after a set date in a PDF. They will be used to cover certain info that is already in the PDF.

    The code:

    <code>var now = new Date() ;
    var expiration = new Date(16,july,2014) ;
    if (now < expiration) {
    this.getField("Cover").display = display.hidden ;
    this.dirty = false ;
    } else {
    this.getField("Cover").display = display.visible ;
    this.dirty = false ;
    } </code>


  • Registered Users Posts: 397 ✭✭The Red


    I only changed the date and the title for the fields which are "buttons" in the Acrobat Fields creator.


  • Advertisement
  • Registered Users Posts: 627 ✭✭✭House of Blaze


    The Red wrote: »
    Ok so, as I said, I am new to this stuff and I got this code somewhere to basically make a set of boxes appear after a set date in a PDF. They will be used to cover certain info that is already in the PDF.

    The code:
    var now = new Date() ;
    var expiration = new Date(16,july,2014) ;
    if (now < expiration) {
    this.getField("Cover").display = display.hidden ;
    this.dirty = false ;
    } else { 
    this.getField("Cover").display = display.visible ;
    this.dirty = false ;
    }
    

    Just so you know, the code tags should be square ones like [ ] on boards!

    So, is it that you want something to appear when the user has selected something and not appear if he hasn't?

    If that's the case, then you should set the display to false by default, and then fire a function in response to the event that triggers when the user changes the value you wish to determine the visibility effect.


  • Registered Users Posts: 627 ✭✭✭House of Blaze


    Unless the if condition is contained within a loop and unless the now variable is incremented then that condition will never evaluate to true.


  • Registered Users Posts: 397 ✭✭The Red


    Sorry, I should be more clear... ok so, I have this set into the Open Page options, as they open the document, this script initiates and after a certain date, the entire PDF (15 pages of interactive fields, calculations and menus) are covered by "buttons" over the whole of each page, effectively "voiding" the document. All the user will see is a grey page with the term "Document is now void, Please contact admin" etc.

    And yes, I know this is by FAR not a very effective way to void a PDF document after a certain period but its all I have atm and the users are NOT savvy enough to bother find a workaround.

    But by all means if anyone had a better suggestion, I would LOVE to hear it. The client basically need it to "expire" after a certain date. Then they will issue out a fresh one with a new expiry.


  • Registered Users Posts: 397 ✭✭The Red


    And be aware that I am not very savvy myself on all of this, I am basically learning it as the client requests it.


  • Registered Users Posts: 627 ✭✭✭House of Blaze


    Well as it stands right now, you are initialising 'now' to be the current date when the document is opened and then initialising 'expiration' to be two days from now.

    You then check to see if now is less than expiration and control visibility depending on that, however, since this runs immediately after they are initialised then now will always be less than expiration.

    You need to keep checking the value of date and comparing it to expiration, and you need to increase the value of now as time goes on or else it will never become true.

    The best way to do this is to use a loop to keep on checking the value of expiration. Also, possibly within the same loop even, you need to make sure now is increasing by some amount so that eventually, when it becomes the case that the value of now is greater than expiration, the loop will try and evaluate the expression and the condition will be satisfied.

    Have you worked with loops before?


  • Advertisement
  • Registered Users Posts: 397 ✭✭The Red


    No, Im afraid not... :(


  • Registered Users Posts: 627 ✭✭✭House of Blaze


    The Red wrote: »
    No, Im afraid not... :(

    Never mind!

    Another possibly easier way to do it, is to use Javascripts built in timing functions.

    I'll post some code now in a sec to show you.

    Have a look at this in the meantime. http://www.w3schools.com/js/js_timing.asp


  • Registered Users Posts: 397 ✭✭The Red


    You are a legend... seriously.


  • Registered Users Posts: 627 ✭✭✭House of Blaze


    No worries!

    I would do it something like this anyway.
    <script> 
    
    var expired = new Date(16,july,2014)
    
    var x = setInterval(function(){ isExpired(expired) },3600000);
    
    function isExpired(dateToCheck) {
        var currentDate = new Date();
    
        if(currentDate > dateToCheck)
        {
             document.getElementByID("cover").style.display = "none";
        }
    
    }
    
    </script>
    
    

    I'm not sure what the structure of your document is and I haven't used javascript on a pdf before but it would look something like the above anyway.


  • Registered Users Posts: 397 ✭✭The Red


    Nice one, really, will try this after lunch straight away, is there anything I need to edit before I try it?

    Thanks a lot.


  • Registered Users Posts: 627 ✭✭✭House of Blaze


    This basically uses setinterval with a value of 3600000 (the number of milliseconds in an hour) to call repeatedly call another function called isExpired.

    That function is then passed the expired variable which it then checks against a new date variable that is initialised every time the check is made.

    So what this means is that: Every hour (3600000 milliseconds), pass the expired variable to isExpired.

    isExpired then creates a new date (which will be one hour ahead in time each time this happens) and compares it to expired.

    This will keep happening forever as I have not set a stop condition.

    Eventually, the new date constructed in isExpired will be greater than the value of expired.

    At that point, the element in your document with an ID of "cover" will have it's display value set to none.


  • Registered Users Posts: 627 ✭✭✭House of Blaze


    The Red wrote: »
    Nice one, really, will try this after lunch straight away, is there anything I need to edit before I try it?

    Thanks a lot.

    You may need to depending on the structure of your document, but I can't tell you what that is! ;)


  • Registered Users Posts: 627 ✭✭✭House of Blaze


    Oh and that date string is wrong. Should be:
    Date("July 16, 2014 00:00:01" );
    
    

    Provided you want it to expire at midnight.


  • Registered Users Posts: 397 ✭✭The Red


    AH! Very good, I wanted to include a time too, especially for testing. Thanks.

    Going to test it now...


  • Registered Users Posts: 627 ✭✭✭House of Blaze


    Let me know how you get on!


  • Advertisement
  • Registered Users Posts: 397 ✭✭The Red


    Hmm, no, not working, should "none" be "visible"? As I want the box to display after the date has passed, effectively blocking the document...

    Here is another script that someone had up online that might show a similar layout... https://forums.adobe.com/thread/687455

    But I tried something like this and it wouldnt work when used on an ipad with PDF Expert.

    The document opened, gave the warning and then just stayed open instead of closing.


  • Registered Users Posts: 397 ✭✭The Red


    I think this is the one I found before...
    function Expire()
    {
    // Get the current date and time
    var rightNow = new Date();
    // Setup End Date
    var rightNow = new Date();
    var beginDate = new Date("December 5, 2012 06:15:00 AM");
    var endDate = new Date("June 16, 2013 1:57:00 PM");
    if (rightNow < beginDate || rightNow > endDate)
    {
    app.alert("It has past the time limit. You cannot use this document any further.\n___________________________________________\n\nContact me to continue using this document. Thanks.", 0, 0);
    this.closeDoc()
    }
    }
    
    // execute check expiration code
    Expire();
    


  • Registered Users Posts: 627 ✭✭✭House of Blaze


    The Red wrote: »
    Hmm, no, not working, should "none" be "visible"? As I want the box to display after the date has passed, effectively blocking the document...

    Ah I see what you're doing.

    You have a big white box that covers the content of the document which you want to activate after the expiry?

    I would have thought you had all your content in a div or similar that you would want to then hide after it expired.

    You could do it your way alright by setting it to be display: none at first and then turning it to visible after the expiry alright.

    Should work that way!


  • Registered Users Posts: 397 ✭✭The Red


    Hmm, ok ill have to get back to this soon but I cant right now. Really, thanks for the time and effort, you've really helped someone today :) Feel proud!

    Ill test this again later and post back here with results.

    Again, thanks a lot...

    Ian.


  • Registered Users Posts: 627 ✭✭✭House of Blaze


    The Red wrote: »
    Hmm, ok ill have to get back to this soon but I cant right now. Really, thanks for the time and effort, you've really helped someone today :) Feel proud!

    Ill test this again later and post back here with results.

    Again, thanks a lot...

    Ian.

    No bother. There may be inconsistencies with the api due to it being on a pdf.

    Maybe have a look at this reference from adobe for acrobat to see if you have any joy.

    http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/js_api_reference.pdf

    Cheers.


  • Registered Users Posts: 397 ✭✭The Red


    Ok as an experiment, I tried the code I posted last up there and changed a couple of things, and it worked!!! Well, on my iMac it did... but on an iPad using PDF expert, i doesnt.

    It provided the message as required, but it failed to close the PDF afterwards, effectively rendering it useless as the client could still use it.

    As a final ditch effort, can anyone let me know if there is a reason PDF expert would not be able to execute the code?


    Thanks again guys..


Advertisement