A Call for Tips and Tricks

by Rick Quatro on February 10, 2010

FrameMaker automation is not all about FrameScript and plugins. Sometimes a tip or shortcut can increase productivity, and even small increases add up over time. If you have a FrameMaker tip or trick that you would like to share, please let me know. If I publish one of yours I will give you a free Carmen Publishing Inc. plugin of your choice.

{ 0 comments }

Mike and I started an interesting discussion about using ExtendScript to import images from a base file name that the user enters. One of the key tasks is to figure out how to take a base file name that uses their syntax and derive a full path from it. Based on Mike’s examples, I came up with the following ExtendScript function:

alert (getImagePath ("MSP4321"));

function getImagePath (imageName) {

  var regex = /([A-Z]{3})((\d)\d)(\d\d)/;
  var path = "\\\\server\\Graphics\\$1\\$1$3000-$3999\\$1$200-$299\\$1$2$4.pdf";

  if (imageName.search(regex) !== -1) {
    return imageName.replace (regex, path);
  } else {
    return null;
  }
}

This function illustrates the power of regular expressions. The basic regular expression is this:

Find 3 uppercase letters: [A-Z]{3}

followed by four digits: \d\d\d\d

The parentheses “capture” parts of the match and put them into special variables in the form of $#, where # is a number from 1 to 9. To figure out what number goes with what set of parentheses, you start counting from the left. So, in our regular expression

([A-Z]{3}) will be $1. In our example, this will be MSP.

((\d)\d) will be $2. In our example, this will be 43.

(\d) nested in $2 will be $3. In our example, this will be 4.

and (\d\d) will be $4. In our example, this will be 21.

We can use these variables to build up our path. Notice the $# variables in the replacement string (color-coded for clarity):

"\\\\server\\Graphics\\$1\\$1$3000-$3999\\$1$200-$299\\$1$2$4.pdf"

This will become

"\\\\server\\Graphics\\MSP\\MSP4000-4999\\MSP4300-4399\\MSP4321.pdf"

The backslash in JavaScript is an escape character, so to get the literal backslash character, we have to use 2 where we want 1.

Copy the function into the ExtendScript Toolkit and try a few filenames that use this format, and you will get the correct path every time. Regular expressions are a deep topic, but as you can see, they are very powerful for parsing tasks like this.

-Rick

{ 1 comment }

FrameMaker 10 ExtendScript: The Object Model

June 30, 2011

Thank you to all that attended this webinar. I will post the link to the recording as soon as it is available. In the meantime, here is a link to the FrameMaker Object Model chm file and webinar slides: http://www.rickquatro.com/resources/FM10_ObjectReference.zip Here is a link to the FrameMaker 10 FDK: http://www.adobe.com/devnet/framemaker.html After you install it, the [...]

Read the full article →

ExtendScript Webinars: What Do You Want to Learn?

June 16, 2011

I just finished my second FrameMaker 10 ExtendScript webinar, which I enjoyed immensely. The first one was done in conjunction with Adobe, the second was sponsored by Carmen Publishing Inc. I would like to do more ExtendScript webinars and want to know what topics people are interested in. Please leave comments with suggestions for ExtendScript [...]

Read the full article →

In Memory of Bruce Foster

June 15, 2011

Bruce Foster, creator of many fine FrameMaker plugins, passed away suddenly on Saturday, June 11, 2011. Although Bruce had been diagnosed with multiple myeloma in September 2010, his death still came earlier than was expected. Bruce’s plugins for FrameMaker were BookInfo, ImpGraph, MifSave, MifToFM, RtfSave, and his most famous, Archive. Bruce’s website is now offline [...]

Read the full article →

FrameMaker 10 and ExtendScript Automation Slides and Samples

May 31, 2011

Last week’s FrameMaker 10 and ExtendScript Automation eSeminar went well in spite of a few glitches. Thank you to Adobe and Tom Aldous for graciously hosting and promoting the seminar. Thank you especially to all that attended and submitted questions. As promised, we are making the slides and sample scripts available for download. You can [...]

Read the full article →

Autonumber Problems

September 30, 2010

Here is part of a recent post on the Framers list: Single-file doc with four Sections. Sections and sub-sections numbered 1, 1.1, 1.1.1 etc. Pgf numbering formats: Heading1 S:<n+>.< =0>< =0>< =0> Heading2 S:<n>.<n+>< =0>< =0> Heading3 S:<n>.<n>.<n+>< =0> But I’m getting Sections 1 and 2 (with subsections), then 5 and 6 (which should be [...]

Read the full article →

Lining up a Table Across Columns

September 14, 2010

This question comes up from time-to-time on the FrameMaker lists, so I will illustrate the problem and solution with four screenshots. You have a single table anchored in a paragraph in the left column. As the table flows from column-to-column, the top of the table in the first column does not line up with the [...]

Read the full article →

Setting Acrobat Bookmarks for a Book

September 9, 2010

When you save a FrameMaker book to PDF, you are presented with the PDF Setup dialog box, where you can set which paragraphs (or elements) you want to appear as bookmarks in the PDF. Often, you will set the Include formats and levels just how you want them, but when you make the PDF, one [...]

Read the full article →

Fun with Acrobat Forms

June 7, 2010

I have created a great workflow for developing Acrobat forms, using FrameMaker, FrameScript, and TimeSavers from MicroType (http://www.microtype.com). Using this workflow makes it practical to use FrameMaker to develop PDF forms. FrameMaker’s graphic and table features can be used to layout great looking forms, while TimeSavers eliminates nearly all of the required Acrobat post-processing. A [...]

Read the full article →

Renaming DITA Map Topics

March 24, 2010

I have a client using MIF2Go to generate DITA from unstructured FrameMaker documents. They are very happy with the entire process with one exception: They want an easy way to rename the href values in the DITA map, and the corresponding topics on disk. I have proposed a set of FrameScript scripts that will automate [...]

Read the full article →