Prerequisite knowledge
 
Familiarity with Adobe InDesign
 
User level: Intermediate
 
Required Adobe products
 
  • Adobe InDesign CS6 or CC
Additional required other products
 
  • Spreadsheet or database for editing CSV files
This script (Assign Button URLs) has been tested with InDesign CS6 and InDesign CC.
 
assign-button-urls-sample-files.zip
Sample InDesign CC file and CSV data file. IDML file provided for earlier versions of InDesign.
 
By downloading software from the Adobe Web site you agree to the terms of our license agreement. Please read it before downloading.
 
 
Note: If you have questions about this article, use the tutorial feedback link at the bottom of the article. Please don’t contact technical support with questions about Adobe Developer Connection articles.
 

 
Introduction

Many DPS projects require buttons which—when activated— display a web page within a view area. While it isn’t too much trouble to create these buttons in InDesign, it can be tiresome to do so when a large number of URLs need to be added or updated.
 
Indeed, button management can be a major hassle for catalog retailers who create hundreds of “Buy Now” buttons which link to product URLs in their DPS projects.
 
At the 2013 Adobe Max Conference, I met Justin Putney (see his bio here) and shared this problem with him. Justin was kind enough to create a terrific script that makes short work of creating and updating button URLs.
 
The script works by searching for button names in your InDesign file and then assigning a URL that matches from a data table on the pasteboard or from an external CSV file.
 
This article covers how to install and use Justin’s Assign Button URLs script for InDesign. It’s easy to try yourself using the sample files above.
 

 
Installing the Script

Start by downloading the Assign Button URLs script above. The file name is “assign-button-urls.zip”. You will need to unzip the ZIP file to access the assignButtonURLs.zxp file.
 
 
Easy Installation Method
  1. Quit Adobe InDesign if it is already open
  2. Double-click the assignButtonURLs.zxp file to launch the Adobe Extension Manager.
 
Alternate Method
If the method above does not work for you, follow the steps below.
 
  1. Quit Adobe InDesign if it is already open
  2. Open the Adobe Extension Manager
  3. Click the Install button
Figure 1: Click the Install button in the Adobe Extension Manager to located and install the script.
Figure 1: Click the Install button in the Adobe Extension Manager to located and install the script.
 
  1. Locate the assignButtonURLs.zxp and click OK.
  2. The script will be installed.
Figure 2: The Adobe Extension Manager shows that the script has been installed.
Figure 2: The Adobe Extension Manager shows that the script has been installed.
 
  1. Close the Adobe Extension Manager

 
Button Names are Important

The Assign Button URLs script basically is a matching program. Here’s how it works . . .
 
In the sample file, I have included a pasteboard data table and also a CSV file which are used as the source of the URLs.
 
In these tables, the items are named 100, 102, 102, etc. Here is the header row and first line of data from the data table:
 
Item Description URL
100 Astatheros nourissati http://www.ricksfish.com/fish/100
When the script runs, it looks for a button named “100” and then matches it to the “100” it finds in the corresponding row of the data table. The script then extracts the data in the URL fields of that row and adds it to the button.
 
So, what does that mean for you? You will need to name your button to match an entry in the data table:
 
Figure 3: The Item column in the data table corresponds to the button name.
Figure 3: The Item column in the data table corresponds to the button name.
 
 
Creating and Naming Buttons
If you are not familiar with creating and naming buttons, here is a quick introduction.
 
  1. Use the Rectangle tool or Ellipse tool, to draw the button shape. You can use the Type tool to add text to the button, such as “Buy Now”.
  2. Use the Selection tool  to select the shape that you want to convert to a button.
  3. Click the Convert Object To A Button icon in the Buttons panel (choose Window > Interactive > Buttons). Or, choose Object > Interactive > Convert to Button.
  4. In the Name text box, specify a name for the button to distinguish it from other buttons you create. Retailers may wish to assign a product ID that uniquely identifies the button.
Note: It is not necessary to give the button an Action. The Assign Button URLs script will do this for you.
 

 
Open the Sample Document and Try the Script

Follow these steps to get started with the script:
 
  1. Unzip the Sample Files folder and place on your desktop or other convenient location.
  2. Launch Adobe InDesign CS6 or CC.
  3. Open fish_catalog.indd (for InDesign CC) or fish_catalog.idml (for previous versions of InDesign)
 
Using the Script with Data on the Pasteboard
The Assign Button URLs script can add or update button URLs from a data table on the document pasteboard.
 
It is convenient  to manage your data on the pasteboard if your URL list is rapidly changing and the data isn’t available in CSV format.
 
Here’s how to update Button URLs in the sample document from the pasteboard data table.
 
  1. Go to page one of the sample document.
  2. Scroll to the left, if necessary, to select the text frame containing the data table:
Figure 4: Make sure you select the container text frame, not the table itself.
Figure 4: Make sure you select the container text frame, not the table itself.
  1. Choose Windows> Utlities> Scripts
      a. Open the Application section then the AJAR Productions section
       
      b. Double-click on the Batch Assign URLs to Buttons script
       
Figure 5: The Scripts panel showing the Batch Assign URLs to Buttons script.
Figure 5: The Scripts panel showing the Batch Assign URLs to Buttons script.
 
  1. The Batch Assign URLs to Buttons window opens.
      a. Select the Table radio button
       
      b. In the left column, select the Item ID column from your data table
       
      c. In the right column, select the URL column from your data table
       
Figure 6: You will need to select the columns for the button field names and URL fields.
Figure 6: You will need to select the columns for the button field names and URL fields.
 
  1. Click OK
  2. The script will run and report the number of new and updated URLs:
Figure 7: The script reports on the number of URLs that were added or updated.
Figure 7: The script reports on the number of URLs that were added or updated.
 
If you select a button and open the Buttons panel, you will see that a URL has been added to the button:
 
Figure 8: The Button panel shows the the URL has been added.
Figure 8: The Button panel shows the the URL has been added.
 
Using the Script with CSV Data
The Assign Button URLs script can add or update button URLs from an external CSV file. A CSV file may be produced from  a spreadsheet program like Excel or from a database.
 
This CSV approach is especially convenient for retailers who produce a series of campaign URLs which may be used to track conversions from the DPS application.
 
Here’s how to update Button URLs in the sample document from the sample CSV file provided.
 
  1. Go to page one of the sample document.
  2. Choose Windows> Utlities> Scripts
      a. Open the Application section then the AJAR Productions section
       
      b. Double-click on the Batch Assign URLs to Buttons script
       
Figure 9: The Scripts panel showing the Batch Assign URLs to Buttons script.
Figure 9: The Scripts panel showing the Batch Assign URLs to Buttons script.
 
  1. The Batch Assign URLs to Buttons window opens.
      a. Select the CSV radio button
       
      b. Click the Load from CSV button . . .
       
      c. Locate the sample_data.csv file and click OK
       
  2. The script window will display the first row of data from the CSV file
      a. In the left column, select the Item ID column from your CSV file
       
      b. In the right column, select the URL column from your CSV file
       
Figure 10: Select the button field name in the CSV and the URL field in the CSV
Figure 10: Select the button field name in the CSV and the URL field in the CSV
  1. Click OK
  2. The script will run and report the number of new and updated URLs:
Figure 11: The script reports on the number of URLs that were added or updated.
Figure 11: The script reports on the number of URLs that were added or updated.
If you select a button and open the Buttons panel, you will see that a URL has been added to the button:
 
Figure 12: The Button panel shows the the URL has been added.
Figure 12: The Button panel shows the the URL has been added.

 
Updates, too!

The Assign Button URLs script can also update existing buttons with URLs. If you change the pasteboard data table or import an updated CSV file using the script, it will update the existing buttons:
 
Figure 13: The script can also update button URLs. In this case, three were updated.

Figure 13: The script can also update button URLs. In this case, three were updated.
 
 
Preview the Page

The data table and the CSV file include links to a live demo site (Rick’s Fish). My hobby is breeding tropical fish, so that was a natural genre for me to use.
 
To preview and test operation of the URL on your Mac or PC:
 
  1. Choose File>Folio Preview
  2. Click a button to test it

 
Resources

Comments are currently closed as we migrate to a new commenting system.  In the interim, please provide any feedback using our feedback form. Thank you for your patience.