Live Hit-Counter inside PDF document

I need to put a "hit counter" into a PDF.

FYI - a "hit counter" is a numerical graphic which lives behind a CGI script on a server, and each time it's loaded, it incriments by one.  It tells in real-time how many people have accessed the document (usually a web page or word document - and I need one for my PDF).  If the user is offline, the graphic will appear "broken" and won't count (not an issue in my case - docs are all online)

How do I get Acrobat to draw the counter from my server, instead of embedding the "00001" initial static graphic on the page?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Karl Heinz KremerCommented:
This is not really a use case that PDF was created for.

Do you want to track one specific PDF file (e.g. every copy on it's own), or one PDF document, regardless of how often it gets copied?

You may have to resort to a true Digital Rights Management (DRM) implementation to do this. But before we go there: Why do you want to do this?
Karl Heinz KremerCommented:
One more question: Does this have to work with the free Reader, or is the full version of Acrobat sufficient?
ChrisDrakeAuthor Commented:
One PDF document, regardless of how many copies: so the counter is an accurate indication of the number of times the document's been opened (and depending on what brand of counter - an estimate of the number of people who've read it).

I know DRM can do this, since the reader connects to the DRM server upon each opening and hence web logs can be used to reconstruct the counter stats, but that's a messy and expensive solution, and doesn't tell the person with the document how often it's been opened easily.

The "full version" of acrobat is OK to create the PDF, but of course it needs to work on the free reader - but then - all PDF's do work on the free reader - that's the whole point.

As for what PDF was created for... don't get me started!!!  It's for printing stuff on paper - shipping documents around to be opened online is what HTML is for, and it works 100 times better, faster, and more often than PDF ever will :-)
Unfortunately, this doesn't deter my customers, so we're stuck with the stupid format whether we like it or not.
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

Karl Heinz KremerCommented:
You are right, PDF files open in both Reader and the full version of Acrobat, but the full version has a number of features that would help you in this case (e.g. online database access). I don't think you will be able to solve this with just Reader. There is no way (none I'm familiar with) to add online content to a PDF file with just Reader.
ChrisDrakeAuthor Commented:
Unfortunately I can't remember where I found the PDF bytecode specs, but I read through them some time back and noticed a bunch of things dealing with online stuff - nothing as obvious as "referencing external images", but there were a number of things that made me go "Hmmm - that's handy" and wedged partly in my brain, so I'm reasonably confident that this is actually possible.  I doubt any of the various tools people use to create PDFs would support the full set of all the underlying PDF-file-format features that the free reader can process, so what I don't know is whether any particular tool can make use of those external-dereferencing commands I read about...

I've just spent 30mins hunting down the specs (why didn't I bookmark them? Sheesh!!) but with no luck.  I'll return and post details if I can find them later.
ChrisDrakeAuthor Commented:
hehehe - typical - as soon as I hit submit, I found the specs again...  I quote from "PDF Reference
fourth edition
Adobe® Portable Document Format
Version 1.5"

This time I read a different bit of the spec (the preamble, rather then the content-stream-operator-summar-appendix of last time), and it specifically states that v6 (at least) of the player can do this:-

9.1 Multimedia
PDF 1.5 introduces a comprehensive set of language constructs to allow the following
• Arbitrary media types can be embedded in PDF files. (See implementation
note 127 in Appendix H for a list of media types that are recommended for use
with Acrobat 6.0 viewers).
• Embedded media, as well as referenced media outside a PDF file, can be played
with a variety of player software. (In some situations, the player software may
be the viewer application itself.)
Note: The term “playing” can be used with a wide variety of media, and is not restricted
to audio or video. For example, it may be applied to static images such as
• Media objects may have multiple renditions, which can be chosen at play-time
based on considerations such as available bandwidth.


So yeah - as you can see - a hit counter is "playable media" (including a JPEG) "as referenced .. outside a PDF file", so I'm back to the problem of finding a PDF composition tool or command or something to let me put this baby *in* my files!
Karl Heinz KremerCommented:
You can certainly try to use the media option. This page has a few links to JavaSciript related documents:

You probably want the "Multimedia JavaScript Reference" which is only available to ASN members (an anual membership is at least $195). The SDK does come with some multimedia JavaScript examples.
ChrisDrakeAuthor Commented:
JavaScript relates to how web pages can embed and control PDF documents - it's nothing to do with how PDF files are created which reference media outside them.  Correct me if I'm wrong, but I didn't think PDF files included any kind of internal scripting support, let alone JavaScript.
Karl Heinz KremerCommented:
Acrobat also comes with it's own JavaScript interpreter. PDF files can therefore come with embedded JavaScript that's executed on certain events. You can actually store JavaScript in three different places:
On the application level. This allows you to e.g. add menu buttons or tool buttons to the application.
In interactive form fields to run a JavaScript when e.g. a button on the PDF file is clicked.
On the document level, to run a JavaScript when e.g. a document is about to be printed.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ChrisDrakeAuthor Commented:
Hey cool - I stand corrected!

Scripting definitely has promise - what tools aid with the insersion of scripts into PDF documents, so you know?
Karl Heinz KremerCommented:
You would use Adobe Acrobat 6.0 Professional to create and debug scripts. If you have some JavaScript background (or are willing to learn), the "Acrobat JavaScript Scripting Reference" and "Acrobat JavaScript Scripting Guide" have everything you need to get started. You can find a number of scripts in this TA if you need more samples. The problems start when you want to control the multimedia features. For this, you need the  "Multimedia JavaScript Reference", which is only available to ASN members. The Acrobat SDK (again, only available to ASN members) has more sample programs.

You can still get the Acrobat 5 SDK without an ASN membership, which also has more JavaScript samples:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Acrobat

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.