1 Reply Latest reply on Jul 30, 2012 10:03 AM by George_Johnson

    Creating and tracking counters in Acrobat

    steve1dance

      I need to create a PDF document that is "aware" of how many times it has been opened.  What i want is the capability to send a document for evaluation but place a limit on how many times the document has been viewed, displaying a message to the user when the limit has been reached.  I found this code on another post and I just want to make sure that it will work (obviously the code does not include the message box).

       

      Many thanks for your help

       

      if (global.count = null)

      {

      global.count = 0

      global.setPersistent("count",true)

      }

      else

      global.count++

        • 1. Re: Creating and tracking counters in Acrobat
          George_Johnson MVP & Adobe Community Professional

          That's not the right way to check for the existence of a global variable. If a global variable does not exist, it will return a value of undefined, not null. Also, the code has a bug such that it actually sets the global to null rather than testing to see if it's equal to null.

           

          Try something like this:

           

          if (typeof global.count === "undefined") {

              global.count = 0;

              global.setPersistent("count", true);

          } else {

              global.count++;

          }