Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.82 KB | None | 0 0
  1. 1. Adobe Acrobat DC allows JavaScript for automation, but there are multiple things which are not done by default during Acrobat Installation and you need to do them before you start scripting
  2. 2. To test JavaScript click Ctrl+J being in Acrobat DC and type-in into console
  3. app.alert("Test")
  4. Leave your coursor on this line and hit Ctrl+Enter to execute (if you don't know this shortcut there is no way to execute it)
  5. You will see the pop-up message "Test". Great!
  6. 3. JavaScript is seen as security threat. To meet security challenge, there is a concept of Folder Level Scripts. There are two folders called in Acrobat as "app" and "user", where the scripts should be stored to grant them highest security access. In Acrobat DC (Septbember 2019) the folders should be located in the following places: the path to "app" folder is "/C/Program Files (x86)/Adobe/Acrobat DC/Acrobat/JavaScripts", the path to "user" folder is "/C/Users/<User>/AppData/Roaming/Adobe/Acrobat/Privileged/DC/JavaScripts"
  7. 4. Surprise! The "user folder doesn't exist by default you need to go to "/C/Users/<User>/AppData/Roaming/Adobe/Acrobat", where <User> is your OS user folder and create the rest of subfolders yourself.
  8. 5. Once it is done. You can check the folders in the console. Go back to Acrobat, click Ctrl+J, enter the lines below one by one and execute pressing Ctrl+Enter. If all good, you are done. It is so dare of Adobe not to explain this somewhere in one place.
  9. app.getPath("app", "javascript")
  10. app.getPath("user", "javascript")
  11. 6. Be patient while doing JavaScript for Acrobat. There are multiple widely unspoken rules you need to follow which are discributed all over the documentation or just Google. For example,
  12.  
  13. The method Doc.importTextData() is used to import data into an interactive form. For this to work, you have to make sure that everything the function needs is in place:
  14.  
  15. * You need a tab separated text file (not a CSV file, the data fields need to be separated by tabs).
  16. * Your PDF form needs to have exactly the same number of fields as there are columns in the text file
  17. * The columns in your text file need to be named exactly like the fields in your form
  18.  
  19. When you import a text file into your form, you will select which row you want to import. This is done via the user interface if you use the functionality on Acrobat's UI, or via a parameter when you call the JavaScript function. Using the UI (e.g. via Forms>Manage Forms Data>Import on Acrobat 9's menu) is an easy way to verify that your file is correct without having to call the JS function.
  20.  
  21. The data gets imported into your form. If you want to access the data, you will have to do this via the form field. You cannot import more than one row at a time. if you need data from multiple rows, you will have to do this one row at a time and then store the data in your own JS data structure.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement