JavaScript to store the file open count in a text file

Hi,
Can we write a javascript in pdf such that when the pdf file is opened, the file open count is stored in a text file locally. Every time, the pdf file is opened, the count should be incremented in the text file. This is basically to check how many time a particular pdf file is opened by an user.
The text file path should be defined in the javascript.

Reader is not able to write to a text file, so you will have to use a global persistent variable.
The script you would use is very simple, and should be set up to run when the document is opened. You can do this by creating a document-level script. The code can look something like:
// Set up a routine that creates
// and/or increments a global count
// variable that keeps track of how
// many times the document has been
// opened on this machine
(function () {
    // Set up the variable name
    // This needs to be unique for each document
    var count_var = "my_doc_open_count";
    // Create global variable if it doesn't already exist
    // and make it persistent
    if (typeof global[count_var] === "undefined") {
        global[count_var] = 0;
        global.setPersistent(count_var, true);
    // Increment the counter
    global[count_var] += 1;
    // Notify user how many times the document has been opened
    // This is mostly for testing, so comment it out if not needed
    app.alert("This document has been opened " + global[count_var] + " times.", 3);
Read the Acrobat JavaScript reference and the accompanying scripting guide for more information. Note that Reader users may have to enable the use of globally persistent variables for this to work.
George

Similar Messages

  • Illustrator CS6 does not store the last opened files

    I need Help,
    Illustrator CS6 does not store the last opened files.

    THat indicates a permissions issue on your preferences file and/ or your files are stored on some external or network device that doesn't use persistent file paths. Look into that.
    Mylenium

  • When I click email links on firefox, it won't open my AOL email client to continue, I get "The file may not be supported by AOL, AOL will try to open it as a text file if you choose to continue" how to fix?

    When I click email links on firefox, it opens AOL, but comes up like this.. "The file may not be supported by AOL, AOL will try to open it as a text file if you choose to continue" how to fix? and yeah, I know, ditch AOL and all that good stuff, but I have so many things tied into my email address that it's not in the cards atm..
    Thanks!
    *Chris

    That file might have moved to a different location on the server. I think you'll need to check with RefWorks support or your local IT department on why the install page links do not work.

  • How do I change the default "open with" application for certain files??  I've tried EVERYTHING!!

    Hi guys!
    PLEASE PLEASE PLEASE someone help me!!!  I have been trying for ages to change this!!  It is SO frustrating!!  I recently bought a new MacBook Pro 13" after my old one (2009) got stolen.  Went from Snow Leopard to 10.8.2, restored all my apps and files etc (thanks goodness I backed up).
    NOW I have a problem!  All my .xls and .doc files open up with Pages and Numbers, and not OpenOffice.  NO MATTER WHAT I DO!!!
    The basic "change open with" "always use this application" story doesn't work.  It always reverts back to Pages or Numbers.  I also tried a Terminal Command I found on this forum from way back in 2010.  But that doesn't work either.  I also tried a .pst deletion but I don't have a .com.apple.launches.pst file!
    PLEASE GUYS.  PLEASE!  SOMEONE HELP ME HERE!!!!!!!!!!  It's driving me nuts!!!!!  LIKE NUTS!!!!!!!

    Here is what I would do:
    Update OpenOffice to the latest Mac OS X version for improved compatibiity with Mountain Lion.
    Boot into Safe Mode to clear caches, verify/repair permissions, and rebuild font database, etc.
    Reboot, holding down the shift key until you see a progress bar on the grey boot screen.
    At the login prompt, and before you click the right arrow button to login, press and hold shift again.
    Reboot normally.
    Now follow sig's advice, and specify OpenOffice as the can opener for Word and Excel files.
    If OpenOffice installs into a /Applications folder as individual writer, and sheet applications, then use these names respectively for Word and Excel files.
    LibreOffice (what I use) only offers the LibreOffice application choice.

  • Count lines in text file

    Folks:
    What's the best way to count the number of lines in a text file?
    thanks,
    Kevin

    You can also skip the open/create, you'll still get a file dialog. I guess EOL conversion is also not needed.
    So the most minumalistic code is as follows.
    Has anyone done any benchmarks? Somehow I have the feeling that temporarily creating that big array of strings might not be the most efficient compared to reading all as one string and counting linefeeds. Who knows...? How big are your files?
    Message Edited by altenbach on 09-29-2006 04:03 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    CountLines.png ‏1 KB

  • How can I find out the number of lines in a text file?

    How can I find out the number of lines in a text file?

    java.io.BufferedReader in = new java.io.BufferedReader( new java.io.FileReader( "YourFile.txt" ) );
    int lineCount = 0;
    while( in.readLine() != null )
    lineCount ++;
    System.out.println( "Line Count = " + lineCount );

  • I was given an assingment, but have no idea where to begin. The assingment is to create a text file using notepad with all of my digital inputs and some how make those imputs show up on my digital indicators on my control pannel

    I was given an assingment, but have no idea where to begin. The assingment is to create a text file using notepad with all of my digital inputs and some how make those imputs show up on my digital indicators on my control pannel.
    When it was explained to me it didn't sound to hard of a task, I have no LabVIEW experience and the tutortial sucks.

    StevenD: FYI, I did NOT give you the one star rating. I would never do that!
    StevenD wrote:
    Ow. Someone is grumpy today.
    Well, this is an assignment, so it is probably homework.
    Why else would anyone give HIM such an assigment, after all he has no LabVIEW experience and the tutorials are too hard for him?
    This would make no sense unless all of it was just covered in class!
    This is not a free homework service with instant gratification.
    OK! Let's do it step by step. I assume you already have a VI with the digital indicators.
    "...but have no idea where to begin".
    open notepad.
    decide on a format, possibly one line per indicator.
    type the document.
    close notepad.
    open LabVIEW.
    Open the existing VI with all the indicators.
    (are you still following?)
    look at the diagram.
    Who made the program?
    Does the code make sense so far?
    Is it a statemachine or just a bunch of crisscrossed wires?
    Where do you want to add the file read?
    How should the file be read (after pressing a read button, at the start of the program ,etc.)
    See how far you get!
    Message Edited by altenbach on 06-24-2008 11:23 AM
    LabVIEW Champion . Do more with less code and in less time .

  • What is the maximum number of 263 byte text files that can fit in a folder?

    what is the maximum number of 263 byte text files that can fit in a folder - on a windows 2000 operating system?
    I created a java program that creates these text files.
    It was set to loop 30,000 times.
    It created a total of 21874 html files before throwing a null exception.
    I tried to copy and paste 10 more html files manually and it said not enough disk space.
    however, I made a New Folder in that same folder and I was able to successfully paste the folders in
    there.
    That's interesting.
    It appears there is a size limit in each folder, BUT I can make another folder within that and successfully paste more html files in there
    Does anyone know the rules governing this feature.
    Stephen

    Whatever the answer is, it has nothing to do with Java programming. Microsoft might know, though, and that's where you should look.

  • Open and read from text file into a text box for Windows Store

    I wish to open and read from a text file into a text box in C# for the Windows Store using VS Express 2012 for Windows 8.
    Can anyone point me to sample code and tutorials specifically for Windows Store using C#.
    Is it possible to add a Text file in Windows Store. This option only seems to be available in Visual C#.
    Thanks
    Wendel

    This is a simple sample for Read/Load Text file from IsolateStorage and Read file from InstalledLocation (this folder only can be read)
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using Windows.Storage;
    using System.IO;
    namespace TextFileDemo
    public class TextFileHelper
    async public static Task<bool> SaveTextFileToIsolateStorageAsync(string filename, string data)
    byte[] fileBytes = System.Text.Encoding.UTF8.GetBytes(data);
    StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
    var file = await local.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);
    try
    using (var s = await file.OpenStreamForWriteAsync())
    s.Write(fileBytes, 0, fileBytes.Length);
    return true;
    catch
    return false;
    async public static Task<string> LoadTextFileFormIsolateStorageAsync(string filename)
    StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
    string returnvalue = string.Empty;
    try
    var file = await local.OpenStreamForReadAsync(filename);
    using (StreamReader streamReader = new StreamReader(file))
    returnvalue = streamReader.ReadToEnd();
    catch (Exception ex)
    // do somthing when exception
    return returnvalue;
    async public static Task<string> LoadTextFileFormInstalledLocationAsync(string filename)
    StorageFolder local = Windows.ApplicationModel.Package.Current.InstalledLocation;
    string returnvalue = string.Empty;
    try
    var file = await local.OpenStreamForReadAsync(filename);
    using (StreamReader streamReader = new StreamReader(file))
    returnvalue = streamReader.ReadToEnd();
    catch (Exception ex)
    // do somthing when exception
    return returnvalue;
    show how to use it as below
    async private void Button_Click(object sender, RoutedEventArgs e)
    string txt =await TextFileHelper.LoadTextFileFormInstalledLocationAsync("TextFile1.txt");
    Debug.WriteLine(txt);
    在現實生活中,你和誰在一起的確很重要,甚至能改變你的成長軌跡,決定你的人生成敗。 和什麼樣的人在一起,就會有什麼樣的人生。 和勤奮的人在一起,你不會懶惰; 和積極的人在一起,你不會消沈; 與智者同行,你會不同凡響; 與高人為伍,你能登上巔峰。

  • How to open File open/save dialog for a file saved in the Appl. Server?

    Hi Experts,
       My requirement is that, there will be a link in my BSP page "Link to BI Report" and when the user will click this link, the File open/save Dialog box will appear for a BI Report file that will be in a fixed path in the Application Server. I have checked with <a href="/usr/sap/tmp/bi_report.csv"> tag but it is not working. The BI report file will be currently in the CSV format. Any ideas about how to achieve this? Thanks in advance.

    If you want to work in tabbed view, do it like this:
    Select the move tool. Go to the tab that contains one of the image files.
    Drag the image over the tab that has the blank document (Keep holding down the mouse button). Wait till that tab opens.
    Drag & drop the image into the blank document.

  • Combo box in JavaScript and store the combo box values into database

    i am a developer, i have a task ie.. i have combo box in JavaScript and i have to store the combo box values into database through JavaServerPage..
    i please every one to have a look on this and please reply soon....

    dear sir,
    your suggestions are really greater the god.............
    i have applied as you said , now i am the page as updated and also i nform you that its multi select ....
    i will show the codings , then u will get a clear identification
    <script language= "JavaScript">
    <!--
    function one2two() {
        m1len = m1.length ;
        for ( i=0; i<m1len ; i++){
            if (m1.options.selected == true ) {
    m2len = m2.length;
    m2.options[m2len]= new Option(m1.options[i].text);
    for ( i = (m1len -1); i>=0; i--){
    if (m1.options[i].selected == true ) {
    m1.options[i] = null;
    function two2one() {
    m2len = m2.length ;
    for ( i=0; i<m2len ; i++){
    if (m2.options[i].selected == true ) {
    m1len = m1.length;
    m1.options[m1len]= new Option(m2.options[i].text);
    for ( i=(m2len-1); i>=0; i--) {
    if (m2.options[i].selected == true ) {
    m2.options[i] = null;
    //-->
    </script>
    <form method="POST" name="theForm" action="update.jsp">
    <table bgcolor="white" border="1" cellpadding="5" cellspacing="2" align="center">
    <tr><td align="center">
    <select id=menu1 size=10 multiple>
    <option>javascript</option>
    <option>php</option>
    <option>Zeo</option>
    <option>asp</option>
    <option>jsp</option>
    <option>ajax</option>
    <option>struts</option>
    </select>
    <p align="center"><input type="button" onClick="one2two()" value=" >> "></p>
    </td><td align="center">
    Languages you know:<BR>
    <SELECT NAME="language" multiple>
    <OPTION VALUE="c">C
    <OPTION VALUE="c++">C++
    </SELECT>
    <p align="center"><input type="button" onClick="two2one()" value=" << " ></p>
    </td></tr></table>
    <center><input type="submit" value="update"></center>
    </form>
    <h4><u>Back<h4>
    <script language= "JavaScript">
    var m1 = document.theForm.menu1;
    var m2 = document.theForm.language;
    </script>
    </body>
    </html>

  • How to print the data in a seperate page / text file

    Hi Experts,
    I have created WD program which fetches data from R/3 using RFC. I am using following statement for printing the results:
    wdComponentAPI.getMessageManager().reportSuccess("The value is " + value);
    I am running the code for 20,000 rows. The results are printed on the same IE page. However it becomes difficult to see the results. I want to get the output printed in any of the following ways:
    Option 1
    1) There should be a link in WD program. When the user willl click on the link other IE page should get open and results should be printed in this page.
    Option 2
    2) The ouput should be written in a text file and user can store the file in local machine.
    Please help me.
    Regards,
    Gary

    Just create a function in your WD application that writes these lines (in loop; pass array of strings to the function) on a text file and saved  as a web resource object then have it available for download by the user. Simple as that.
    Search for WD tutorials that involves downloads and using the web resouce object in WD applications.
    This guide should provide you a good feel through the entire approach: /people/bertram.ganz/blog/2007/05/25/new-web-dynpro-java-tutorials--uploading-and-downloading-files-in-sap-netweaver-70

  • Is there a way to automatically add the filename in the page header when batch printing text files directly from finder?

    hello, i have 80 text files (docx). the finder preview works great and i can open them in pages.
    I need to batch print them from finder:
    I select all the documents > drag on printer's icon> printer puts them in queue ( after an on the fly pdf conversion)  ad starts printing.
    BUT
    i need the filename printed on each page  ( in hearder or footer) , not only the regular text content.
    Do you know if there is a workaround?
    thank you
    Tullio

    If that section has an ID or NAME attribute then you can add that to the URL (#anchor) that you want to reload.
    See View > Page Source
    https://support.mozilla.com/en-US/questions/774792#answer-128100

  • How do i add a download action for dxf files. firefox assumes its a text file and just opens it with no download action dialog box

    I want to add a download action for dxf files so they open in Autodesk trueview. The steps described here (http://support.mozilla.com/en-US/kb/Managing%20file%20types#w_adding-download-actions) say to click on a link for the filetype you want to add an action to but firefox thinks the dxf is a text file and just opens it in a new tab with no download action dialog box.

    Use the right-click context menu and choose "Save Link As" or hold down the alt key and left-click the link.

  • File Open Issues - document library pdf file to open in new browser window

    Hi
    I have a requirement to open the document library containing pdf file to open in new browser window. So far I have tried following steps but could not get it to work.
    1. Changing Document library advance setting to open the document in browser (have tried others as well).
    2. SharePoint web application setting changed as Permissive instead of Strict. Here the pdf file opens in browser but redirect from document library instead of new window(Also tried adding Target=”_blank” and no change).
    3. Executed the powershell script to adding MIME type to see if it works but no change.
    $webApp = Get-SPWebApplication http://SharePointSite
    If ($webApp.AllowedInlineDownloadedMimeTypes -notcontains "application/pdf")
    Write-Host -ForegroundColor White "Adding PDF MIME Type..."
    $webApp.AllowedInlineDownloadedMimeTypes.Add("application/pdf")
    $webApp.Update()
    Write-Host -ForegroundColor White "Added and saved."
    Else
    Write-Host -ForegroundColor White "PDF MIME type is already added."
    4. Open the Doc library and modified ALLItems.aspx to add Target= “_blank”
    5. I have already tried solutions suggested in the link:
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/9db08c4a-b53c-419a-84f8-001c194d1311/how-to-open-sharepoint-document-library-pdf-file-in-new-window?forum=sharepointadminlegacy
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/530e2ea1-d77d-491c-935f-04f536e439a5/open-a-pdf-document-to-a-new-browser-in-the-document-library-web-part?forum=sharepointadminlegacy
    http://mindsharpblogs.com/todd/archive/2005/08/16/654.html
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/7b6091df-4657-4799-ba02-259ebd7e4b7c/pdf-doesnt-open-in-document-library?forum=sharepointadminlegacy
    Appreciate if there are any working solution from any of you. Many Thanks

    I found a solution which works only in the development. No idea when I compared, Browser MIME type is enabled, STRICT browser type is configured for web application. on the document library advance setting, default to open in new browser. Both configurations
    are identical but I am able to open pdf file in new window in my developing using jquery script
    http://blog.ithinksharepoint.com/2011/02/21/open-pdf-files-from-a-document-library-in-a-new-window/ but the same does not work on production server :(
    Any help experts?
    Thanks

Maybe you are looking for

  • VAT Process in SAP...Any help...

    Hi experts, I have a small clarification in standard SAP. Can anyone explain me as following.... Our client process is to reconcile export transactions and also waived 7% VAT export customers where submission of the proper documents like delivery ord

  • SCCM 2007 database move from SQL 2008 to SQL 2012 SP1

    Hi, today we tried with moving the sccm DB from our SQL 2008 to SQL 2012. The whole DB process was a success but what bugs me is the reporting services which we also have. Does the reporting service make automatic transition to the box or do i have t

  • Procedure which inserted and returns value

    i don't know english very vell and sorry about it :((( i want write a procedure which inserted or updated table and returns it's ID ... it's my tabel : DROP TABLE T_STUDENT CASCADE CONSTRAINTS; CREATE TABLE T_STUDENT ID NUMBER(10) NOT NULL, NAME VARC

  • Job and Spools

    Hi, In SM36, I create a job with ONE step : run program "prog_1". Then in a special case, in this program "prog_1" :  we submit a second program "prog_2" which create also a log "log_2" .  Then we return to "prog_1" to edit a log "log_1". Resume:   a

  • NUMBER OF CONTACTS IN LIST

    Just got the N80 and am still finding my way around. I have copied all my contacts over -- I hope -- but cannot be sure. I cannot see anything that might tell me the precise number of contacts I have in the address book. Does anyone know where that i