Friday, October 21, 2011

Import by Reference

Two important pieces of information about any imported graphic are :
  • The full pathname of the imported file.
  • The DPI at which the file was imported. 
The following code uses  Err() to display this information in the FrameMaker console. 

The file name is just a string while the DPI is an integer. To display it in the console, requires that it be converted to a string. 

var doc= app.ActiveDoc;
ListGraphics (doc);

function ListGraphics(doc)
     var graphic = doc.FirstGraphicInDoc;
     while (graphic) {
         if (graphic.type == Constants.FO_Inset) {
             Err("     ");
             Err(graphic.InsetDpi + "");
         graphic = graphic.NextGraphicInDoc;

Here is the output from a file with just one imported graphic:

Adding the code line graphic.InsetDpi = 2400; within the loop, resets the image's DPI making it smaller. The console now shows:

NOTE: The console does not get cleared between successive runs of your script. Closing it clears the content.

1 comment:

  1. There is also the undocumented Console() function. The only difference I can see is that Console returns Console() while Err() returns undefined...