Typically the manual process for placing an anchored graphic above line, can be outlined as follows:

  1. Place insertion point in text where image is to be placed
  2. Place graphic (Command/Control + D)
  3. Select graphic from the place dialog (often having to jump through hoops to get to the right folder)
  4. Select the container for the placed image. Escape + V and click on image
  5. With the image container selected, choose Anchored Object > Options from the Object menu
  6. Select Above Line and enter values as appropriate

Option box shown

  1. Click OK
That’s seven steps to place one graphic (which is OK if you have only one or two). For more images, you may consider automating the process.

Before applying anchored object options

It is well to note that an inline graphic is considered by InDesign to be a single character. When the graphic is placed it is styled the same as the paragraph to which it is attached.

In addition to settings in the Anchored Object Options dialog, placement can be modified using character and paragraph styling. 

For a complete set of properties that you can assign to your anchored object, including its placement, consider using an object style.


Create an object style for your project (see settings above). Name it AnchoredGraphic or whatever you prefer.

With the object style created, you can replace steps 5 through 7 above with the following:

Choose the object style from the Object Styles panel. Click OK. (Of course you do have Object Styles as part of the Workspace you are using. If not, select Styes > Object Styles from the Window menu.)

If you have a boat load of images to place, you may consider the few minutes it takes to create a script to execute all of the steps (but the first) above.
Below is a script for starters.

The script does expect that you will have a document open with an insertion point selected in front of the paragraph where the image will be placed.

You will also need to have an object style named the same as the value for the variable objectStyleName at the top of the script (AnchoredGraphic). The script also assumes that the images for your project are in a separate folder named “Images.” (Named the same as the variable folderName at the top of the script).


set folderName to "Images"
set objectStyleName to "AnchoredGraphic"
(*Call handlers and handle errors in on error statement*)
   set insertPoint to getInsertPoint()
   set imageToInsert to getImage(folderName)
   placeImage(insertPoint, imageToInsert, objectStyleName)
on error errStr
   display alert ("Error: " & errStr)
end try
(*Returns reference to insertion point selection or error*)
on getInsertPoint()
   set errorMsg to "Requires insertion point for image placement"
   tell application "Adobe InDesign CC 2015"
      if not (selection exists) then
         error errorMsg
      end if
      set selList to selection
      set selItem to item 1 of selList
      if class of selItem is not insertion point then
         error errorMsg
      end if
   end tell
   return selItem
end getInsertPoint
(*Returns reference to image file selected or error*)
on getImage(folderName)
   set userPrompt to "Choose file for placement"
   tell application "Adobe InDesign CC 2015"
      set docRef to document 1
      set filePath to (file path of docRef) as string
      set dLocation to (filePath & folderName) as alias
      set imageToImport to choose file with prompt userPrompt default location dLocation
   end tell
   return imageToImport
end getImage
(*Places image given insertion point, image reference, and object style name*)
on placeImage(insertPoint, imageToInsert, objectStyleName)
   tell application "Adobe InDesign CC 2015"
      set objstyleRef to object style objectStyleName of document 1
      tell insertPoint
         set placedList to place imageToInsert
         set imageRef to item 1 of placedList
      end tell
      set rectRef to parent of imageRef
      set applied object style of rectRef to objstyleRef
   end tell
end placeImage

Notice that each major process for the script is taken care of (handled) in a subroutine that begins with the word on and ends with end. Values, as needed, are passed to the arguments list (inside the parentheses pair) as part of the on statement. Statements that call the handlers are placed inside a try/end try statement block that takes care of any errors generated in the handlers.


To take care of specific problems you may face in your workflow you can add to the scriptt
If your documents might not have the object style specified, you could have your script test and create the style if needed.

Additionally, your users may have failed to follow instructions and have files other than images in the Images folder. You could prevent the script from trying to place an improper file by making the following changes to the getImage() handler:

on getImage(folderName)
   set userPrompt to "Choose file for placement"
   tell application "Adobe InDesign CC 2015"
      set docRef to document 1
      set filePath to (file path of docRef) as string
      set dLocation to (filePath & folderName) as alias
      set imageToImport to choose file with prompt userPrompt default location dLocation
      set {fileType, fileExt} to my checkFile(imageToImport)
      if not((fileType is not in placeable file types) or (fileExt is not in placeable file extensions)) then
         error "improper file selected"
      end if
   end tell
   return imageToImport
end getImage
(*returns reference to file type and file name extension for alias reference passed*)
on checkFile(imageToImport)
   set fileInfo to info for imageToImport
   set fileType to file type of fileInfo
   set fileExt to name extension of fileInfo
   if fileType is not "" and fileExt is not in {"", "txt", "doc", "docx"} then
      return {fileType, fileExt}
      error "Improper file selected"
   end if
end checkFile

Also,notice that getImage() calls another handler that uses the system to test for file type and file name extension.

Then getImage() uses InDesign’s placeable file types and placeable file extension to make sure the files pass this test. If in testing this script you find some file types that get past the two tests, you will want to add their file type or file name extension to the test in the checkFile() handler.


If you need to add a caption to the graphic, here are two options:

    • If the graphic is between paragraphs, simply add an empty line and use the insertion point for that line to place the graphic. Once the graphic is placed, activate the insertion point below the graphic and enter the caption, setting the caption paragraph style as needed.

  • If the graphic is inside of a paragraph, the solution is not quite as easy. Look for a solution in our next blog post.


Should you have the occasional graphic that needs to be have alignment other than that set for the object style, you can always override the alignment setting for your object style in InDesign’s Anchored Object Options panel (Object > Anchored Object > Options). And, for the graphic that ends up at the top of the page, you can similarly override the space above setting.

If the workload merits the extra effort (will take less than five minutes), save the image in the User section of InDesign’s script panel and assign a keyboard shortcut to the script.

Mac User Hint: Don’t Have the Users Scripts folder in your favorites panel? Control click on the Users folder icon in the Scripts panel and select Reveal in Finder. Drag the panel to your Favorites list. Now all you need to do to add your script to InDesign’s Users scripts panel is to drag it to the Scripts Folder name in the Favorites panel.