The PDF standard includes support for JavaScript, but as @Wes Hardaker noted, not every PDF reader supports it. However, sometimes some are better than no one.
Here's the official Adobe Scripting Guide for Acrobat JavaScript . Probably the most interesting for you is the doc object, which has a method called getURL() . To use it, you simply call:
app.doc.getURL('http://www.google.com/');
Bind this event to an open document and you have a tracker. I'm not too good at creating events from Adobe Acrobat, but from code is pretty easy. The code below is a complete working application VS2010 C # WinForms using the open source library iTextSharp (5.1.1.0). It creates a PDF file and adds JavaScript to an open event.
Some notes . Adobe Acrobat and Reader will alert the user whenever a document accesses an external resource. Most other PDF readers are likely to do the same. This is very annoying, so for this reason it should not be done. Personally, I don’t care if someone is following my document, I just don’t want to get hints every time. Secondly, to repeat this code, this code works for Adobe Acrobat and Adobe Reader, perhaps at least in V6, but it may or may not work in other PDF readers. Thirdly, there is no reliable way to uniquely identify a user. To do this, you need to create and save some equivalent cookie, which will require you to write to the user's file system, which will be considered unsafe. This means that you can only detect the number of discoveries, not a unique discovery. Fourthly, this may not be legal everywhere. Some jurisdictions require you to notify users that you are tracking them and to allow them to see what information you collect.
But with all of the above, I can’t give an answer just because I don’t like it.
using System; using System.Text; using System.Windows.Forms; using System.IO; using iTextSharp.text; using iTextSharp.text.pdf; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) {
Chris haas
source share