I am new to Acrobat javascript, and need to know how to create a visitor counter inside a PDF. The PDF in question resides on a client website, ie. www.client.com/mypage.pdf. The page that is displayed can only be a PDF, no HTML is allowed, using any HTML on www.client.com is out of the question. Everytime the pdf is opened, I want to increase the counter by one. My best guest is that I need to save the counter variable to a file on the www.client.com domain. The logic goes something like this, in a document level script:
. . . // code before . . .
if(!pdfOpened) { // just run one time when pdf is opened
hitCount = getHitCount("http://www.client.com/visitor.txt", fileExists); // get the counter from the text file
if (!fileExists) { // file does not exist then create it
createFile("http://www.client.com/visitor.txt"); // create a text file on the domain
var visitor.txt = 0; // initialize file to zero
saveFile("http://www.client.com/visitor.txt"); // save the text file to the domain
} // end if
hitCount = hitCount + 1; // increment counter
saveHitCount("http://www.client.com/visitor.txt", hitCount); // save it back to the domain
pdfOpened = true; // set to true so it wont run again
} // end if
. . . // code after . . .
How do I open, close, read and append files using Acrobat javascript, so I can read and write a file to a local file, or a remote location such as a text file on the web. Would like to have this work from Acrobat Reader v6 to current version. Any suggestions would be greatly appreciated.
- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com