Resources >>   

ExtendScript Samples

This page contains a set of sample FrameMaker ExtendScript scripts, intended to assist a beginner with getting started. ExtendScript is a powerful interface for the customization and automation of FrameMaker (and other Adobe products), first introduced in FM10. It follows the FDK model in many respects; however, it is much more accessible than the FDK, especially to the new and/or amateur developer.

If you are not using ExtendScript, you are likely missing out on numerous opportunities to improve your FM experience and efficiency by making the product work the way you want. Unfortunately, though, it can be difficult to get started. Therefore, these scripts are provided as a public service to supplement existing resources and documentation. Often, a working example is worth more than anything.

BEFORE YOU DOWNLOAD, please read the following carefully!

  • These samples are not intended as a comprehensive ExtendScript tutorial. They are intended to provide working examples only, to supplement other methods of study and learning.
  • All scripts are heavily commented internally to help you understand how they work. These comments include instructions on how to run each respective script.
  • You must have FM10 or later. The sample FrameMaker files are in FM10 format; however, note that the scripts were authored and tested on FM11 only. It is believed that they should work on FM10, but no guarantees are made. We do not intend to perform any testing or maintenance related to FM10, so for those users, all files are provided strictly as-is.
  • The download package contains a PDF file with basic instructions for running the scripts.
  • ExtendScript capabilities are vast and flexible, which adds a level of responsibility on the developer to code with care. All due diligence was used to ensure that these scripts cause no damage to your computer or data when run on the sample files. However, you should be aware that although unlikely, it is possible to write ExtendScript code that causes catastrophic damage to your FrameMaker data or even other application data. This warning is not intended to discourage you, only to inform, and to positively assert that West Street Consulting can not be held responsible for the outcome of running these scripts, as provided or otherwise altered. Use at your own risk, especially if you plan to experiment and customize!
  • If you have an idea for a sample that is not shown here, contact us and we may be able to provide it, within reason.
  • West Street Consulting is open to proposals for contract ExtendScript development. If a job is not within our bandwidth, we may be able to recommend other competent providers.

If you understand and agree with the notes and terms above, click here to download.

The following table lists and briefly describes all the scripts found in the download package. Any sample files required for the scripts are also found in the package.

Number

Name

Description

0.0

First_script.jsx

A very basic script to ensure that you can actually run a script.

 

01.01

FILE_-_Get_active_document.jsx

Retrieves and reports the currently-active document.

01.02

FILE_-_Get_all_open_documents.jsx

Retrieves and reports all open documents.

01.03

FILE_-_Open_a_document.jsx

Produces a file browser and opens the selected file.

 

02.01

DOC_-_Report_document_properties.jsx

Reports various properties associated with a document object.

02.02

DOC_-_Delete_a_pgf_format.jsx

Deletes a paragraph format from a document.

02.03

DOC_-_Report_all_pgf_formats.jsx

Retrieves and reports all paragraph formats in a document.

02.04

DOC_-_Report_pgfs_and_their_formats.jsx

Retrieves and reports the text from all paragraphs in the main flow, along with their assigned paragraph formats.

02.05

DOC_-_Apply_character_format.jsx

Applies a character format to a range of text.

02.06

DOC_-_Change_pgf_format_font_size.jsx

Changes the font size of a paragraph format and updates all paragraphs that use it.

02.07

DOC_-_Insert_and_replace_text.jsx

Inserts and replaces text in various places in the document.

 

03.01

TABLE_-_Table_selection_and_sizing.jsx

Performs various selection and sizing actions on a table.

 

04.01

GRAPHIC_-_Resizing_and_rotating.jsx

Resizes and rotates a graphic.

04.02

GRAPHIC_-_Import_graphic_and_shrinkwrap.jsx

Produces a file browser to import a graphic, then shrinkwraps it afterwards.

04.03

GRAPHIC_-_Size_to_fit_frame.jsx

Sizes a graphic to fit the existing anchored frame size, like a "reverse" shrinkwrap.

 

05.01

MENUS_-_Create_menu_and_command.jsx

Creates a menu, some commands, and shows how to respond to them.

 

06.01

NOTIFICATION_-_Notify_on_doc_open_and_close.jsx

Shows how to respond automatically to user events, in this case a document open or close action.

 

07.01

BOOK_-_General_book_operations.jsx

Shows how to walk through a book, read component properties, and open chapter files.

 

08.01

STRUCTURE_-_General_activities.jsx

Shows how to walk through a structure tree and set attribute values.

 

09.01

DIALOGS_Basic_palette_-_coordinate_driven.jsx

Shows how to create a dialog box (palette), using a coordinate-based approach.

09.02

DIALOGS_Basic_palette_-_resource_specification_driven.jsx

Shows how to create a dialog box (palette), using a "resource specification" approach.

 

10.02

NETWORK_-_Retrieve_text_over_network.jsx

Shows how to query the internet for content and automatically insert it into a FrameMaker document.

 

100.01

ADVANCED_Graphic_utilities_palette.jsx

An advanced script that produces a palette with sizing, shrinkwrap, and size-to-fit tools for graphics. It is intended as a more comprehensive example showing how to integrate user interface tools with real functionality.

100.02

ADVANCED_Create_formatting_shortcuts.jsx

This is an advanced script provided largely as a gift to the community. It allows you to define Ctrl and Esc key shortcuts that apply character formats to and/or wrap elements around the currently-selected text. It was originally intended to "hijack" common shortcuts like Ctrl+B to apply character formats rather than simple format overrides. Eventually, it grew into a general purpose tool for defining character formatting commands with fully customizable shortcuts. See the comments in the script for important instructions on how to customize it for your environment, including how to define the shortcuts you want and what they should do.

100.03

ADVANCED_-_Verify_hypertext_marker_links.jsx

This script will step through a whole document or book and check all "message URL" Hypertext marker links. It produces a report on all links checked in the process.

100.04

ADVANCED_-_Create_favorites_list.jsx

This script creates a fully-customizable menu of favorite files for quick launch and allows the menu to be placed under any existing parent menu.

100.05

ADVANCED_-_Configure_attribute_displays.jsx

This script creates up to three keyboard shortcuts to configure attribute displays within the Structure View. It operates on the entire structure tree of the main flow and provides the following options: Collapse all attributes, Expand all attributes, and Show populated/required attributes only.