Wednesday, October 19, 2011

Counting Insets

Insets are just imported images. They can be still images or video. From the point of view of the FDK or ESTK scripting, they are a subtype of graphic object.

The list of all graphics in a document is an unordered list. The first graphic in the list is found using the document property  FirstGraphicInDoc. Subsequent graphics can be found using the graphic object property NextGraphicInDoc.

Note: A single insert can have multiple facets. 

Note: The only graphics you can work with in flow order are those that are anchored in text. It is possible to work with selected graphics, graphics on a page by page basis, or those within a particular frame.

Rectangles and other shapes that can be created with the FrameMaker built-in drawing tool are also graphic objects as are text frames both anchored and unanchored. Thus, graphic objects have a type property that makes it possible to distinguish between the differing types.

This script defines a function to count the graphics in the document of interest,

var doc= app.ActiveDoc; 
var count = CountGraphics (doc); 
Alert(count, Constants.FF_ALERT_CONTINUE_NOTE);

function CountGraphics(doc)
    var count = 0;
    var graphic = doc.FirstGraphicInDoc;
    while (graphic) {
         if (graphic.type == Constants.FO_Inset)
         graphic = graphic.NextGraphicInDoc;
    count = count+''; //concatenate empty string to convert
    return (count);   

No comments:

Post a Comment