Listing graphics in order of appearance

Jonathan asked on the FrameScript list on yahoo groups about getting a list of graphic files in a document in order of appearance. I decided to answer it here so I can discuss it in some detail and because yahoo groups doesn’t format code listings very well. There are a couple of possibilities to consider. First, if you don’t have any graphics in tables, you can do something simple like this:

This is a general purpose script for processing paragraphs in document order. Lines 8, 24, 32, and 40 are where you do something with each paragraph. In this case, we can call a function on each of these lines to get any anchored frames that are in each paragraph. The function would be similar to the first code example, except that it would get any anchored frames in each paragraph instead of the entire main flow.

1

2

3

4

5

6

7

8

9

10

11

12

FunctionProcessParagraph oPgf

//

// Loop through all of the anchored frames in the paragraph.

Get TextList InObject(oPgf)FrameAnchor NewVar(tTextList);

Loop While(i<=tTextList.Count)LoopVar(i)Init(1)Incr(1)

// Get each anchored frame.

Set oAFrame=tTextList[i].TextData;

// Get the information on the imported graphic(s) inside the text frame here.

There are some unfinished pieces here, like how to query each anchored frame for imported graphic information. Also, you will need a way to collect the graphic data. But this will get you started. Questions and comments are welcome. If there is enough discussion generated, we can go further with this.