Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6830607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:38:16+00:00 2026-05-26T22:38:16+00:00

Is there a way to track when a PDF is opened? Perhaps by embedding

  • 0

Is there a way to track when a PDF is opened? Perhaps by embedding some script into the pdf itself?

I saw the question below, and I suppose the answer is “no” for javascript, but I am wondering if this is possible at all.

Google analytics tracking code insert in pdf file

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:38:16+00:00Added an answer on May 26, 2026 at 10:38 pm

    The PDF standard includes support for JavaScript but as @Wes Hardaker pointed out, not every PDF reader supports it. However, sometimes some is better than none.

    Here’s Adobe’s official Acrobat JavaScript Scripting Guide. What’s probably most interesting to you is the doc object which has a method called getURL(). To use it you’d just call:

    app.doc.getURL('http://www.google.com/');
    

    Bind that event to the document’s open event and you’ve got a tracker. I’m not too familiar with creating events from within Adobe Acrobat but from code its pretty easy. The code below is a full working VS2010 C# WinForms app that uses the open source library iTextSharp (5.1.1.0). It creates a PDF and adds the JavaScript to the open event.

    Some notes: Adobe Acrobat and Reader will both warn the user whenever a document accesses an external resource. Most other PDF readers will probably do the same. This is very annoying so for this reason alone it shouldn’t be done. Personally I don’t care if someone tracks my document opens, I just don’t want to get a prompt every time. Second, just to reiterate, this code works for Adobe Acrobat and Adobe Reader, probably as far back as at least V6, but may or may not work in other PDF readers. Third, there’s no safe way to uniquely identify the user. Doing so would require you to create and store some equivalent of a “cookie” which would require you writing to the user’s file system which would be considered unsafe. This means that you could only detect the number of opens, not unique opens. Fourth, this might not be legal everywhere. Some jurisdictions require that you notify users if you are tracking them and provide for a way for them to see what information you are collecting.

    But with all of the above, I can’t not 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)
            {
                //File that we will create
                string OutputFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Events.pdf");
    
                //Standard PDF creation setup
                using (FileStream fs = new FileStream(OutputFile, FileMode.Create, FileAccess.Write, FileShare.None))
                {
                    using (Document doc = new Document(PageSize.LETTER))
                    {
                        using (PdfWriter writer = PdfWriter.GetInstance(doc, fs))
                        {
                            //Open our document for writing
                            doc.Open();
    
                            //Create an action that points to the built-in app.doc object and calls the getURL method on it
                            PdfAction act = PdfAction.JavaScript("app.doc.getURL('http://www.google.com/');", writer);
    
                            //Set that action as the documents open action
                            writer.SetOpenAction(act);
    
                            //We need to add some content to this PDF to be valid
                            doc.Add(new Paragraph("Hello"));
    
                            //Close the document
                            doc.Close();
                        }
                    }
                }
    
                this.Close();
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Question: Is there any way to track how many website visitors are leaving your
Is there a way to track when a radio element gets deselected? <script type=text/javascript>
Is there a way to programatically track the size of a particular session on
Is there a simple way to track the motions of a single entity in
Is there any way in Google Analytics to track whether somebody who completes Goal
Is there a simple way to scale the pdf created by cfdocument or cfpdf
Is there a way to track marketing campaigns in the app store to find
Is there any way, to track dynamically which classes or modules are included in
Is there a way to track the right click menu when clicked over a
Is there a way to track user activity in Microsft Dynamics CRM? The end

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.