• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Import Multiple Icons

Participant ,
Jan 22, 2020 Jan 22, 2020

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:

  1. Place the photo report template in the same folder as all the photos to be imported; all photos in the folder with it are automatically imported
  2. The user opens an import dialog which allows multiple files to be selected
  3. The user creates a list with file names (or partial file names) and provides a path to the photos

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.

TOPICS
Acrobat SDK and JavaScript

Views

148

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 22, 2020 Jan 22, 2020

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 22, 2020 Jan 22, 2020

Copy link to clipboard

Copied

LATEST

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. 

 

 

 

 

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines