[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 680
  • Last Modified:

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?
0
ChrisDrake
Asked:
ChrisDrake
  • 6
  • 5
1 Solution
 
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?
0
 
Karl Heinz KremerCommented:
One more question: Does this have to work with the free Reader, or is the full version of Acrobat sufficient?
0
 
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.
0
Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

 
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.
0
 
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.
0
 
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
capabilities:
• 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
JPEGs.
• 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!
0
 
Karl Heinz KremerCommented:
You can certainly try to use the media option. This page has a few links to JavaSciript related documents: http://partners.adobe.com/asn/acrobat/docs.jsp#javascript

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.
0
 
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.
0
 
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.
0
 
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?
0
 
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: http://partners.adobe.com/asn/acrobat/download.jsp#fullinstall
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now