Copy link to clipboard
Copied
The project I'm working on is a photo report. The technician filling it out looks at a photo log and adds 6 or more photos and captions to the PDF before printing it. I have each photo button set up like so:
event.target.buttonImportIcon();
I know that this method has security restrictions (a red 'S' in its quick bar in the Acrobat API Reference), although I don't completely understand that. When am I not able/unable to call such methods? I ran into this first when trying to spawn a blank page from a button (I ended up discovering and using templates this way).
However, I digress. My real question is can I set up a document that can import multiple icons in one shot? The file will be stored on a remote server (as well as the photo files its importing), and there is noticable lag while importing. I would like to be able to handle it one of the following ways:
I am okay with this requiring Folder level script, if that's the only option. I just want to reduce the number of times the user waits for files to be imported to one.
Copy link to clipboard
Copied
Yes, if you run the script from a privileged context (eg. a trusted function in a folder-level script) you can specify the file path of the icon to import (it needs to have the correct syntax, though), and then use a loop to read the paths from a text file, for example, and apply them to multiple buttons in a single process.
Copy link to clipboard
Copied
Read these articles to understand how script security and folder level scripts:
https://www.pdfscripting.com/public/Trust-and-Privilege-in-Acrobat-Scripts.cfm
https://www.pdfscripting.com/public/Automating-Acrobat.cfm
Because of trust issues, Acrobat doesn't have a general file selection mechanism that provides direct access to the user's file system. Generally, for button icons the field.buttonGetIcon() function would be called without a path. The user selects teh file, Acrobat places the icon, but the script never knows the real path.
That said there are a couple of ways to do this .
1. Use the app.browseForDoc() method. Can only be used from a privileged context. Automatically filters for "*.pdf" files. but the user can override it by typeing thier own filter into the file field. Only selects one file at a time.
2. use a text field with the "field.browseForFileToSubmit()" function. The text field property "fileSelect" must be set. Can only be used for single file selection, but will work without privilege.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now