2 Replies Latest reply on May 14, 2009 1:36 PM by try67

    Simple Task Probably, but I'm really new to JavaScript

    Joe The Engineer Level 1

      Sorry, but i'm very new to Javascript and i'm trying to figure out how to do a pretty simple thing.

       

      I want to execute a javascript in an adobe button that will:

       

      a) open a .txt file in certain location

      b) replace the text of the txt file with the name of the button being clicked (meaning i don't want to hardcode the button name into the javascript, but instead reference it to the particular button name (actually the text that the button displays...i'm not sure if the name of the button is the same as the caption of the button???)

      c) save and close the txt file

       

      I'd like all of the above to execute without the txt file ever being shown...is that possible?

        • 1. Re: Simple Task Probably, but I'm really new to JavaScript
          Patrick Leckey Level 3

          I'd like all of the above to execute without the txt file ever being shown...is that possible?

          Yes and no.  Acrobat JavaScript doesn't give you direct access to the file system, so you would need to do the following:

           

          1. Embed the text file as a dataObject

          2. Extract the contents of the dataObject

          3. Do whatever you want to do with that content

          4. Replce the content of the dataObject with whatever your result is

          5. Export the dataObject to disk

           

          Because working with the file system is a security concern, steps 1 and 5 can only be executed from a folder-level script, manually from the JavaScript console, or in a batch process.

          • 2. Re: Simple Task Probably, but I'm really new to JavaScript
            try67 MVP & Adobe Community Professional

            Also, for versions 6.0 or higher, step 5 will produce a file save dialog which the user will have to confirm in order for the file to be saved.

            So you can't really do this in a completely transparent way.