Placing an image over an InDesign table cell

While working on my upcoming Sudoku book (Sudoku Atlantis) I came up with a new need for placing images in my puzzle grid. All of my publishing is done using Adobe InDesign CS5 with a C# program I use as a GUI generating JavaScript code which is then run in InDesign.

Previously I had simply set up a 9x9 array of rectangles on a separate layer within my InDesign template and manually aligned it with the puzzle grid. This worked well enough but I wanted to have a little more flexibility.

What I want to do is be able to create a rectangle in the exact position and size as a table cell.

I first thought this would be easy since InDesign elements have a "geometricPosition" property. This property returns an array [y1,x1,y2,x2] which gives the coordinates of the upper left and lower right edges of the element. Unfortunately, this only applies to "page items", effectively anything you can pick up and drag to a new position in InDesign. Neither a table nor its cells are position independently of the text frame in which the table has been placed.

After some work I came up with a set of functions in JavaScript to work around this.

 

The first function is FindTableBounds. By passing in an InDesign table reference, it will return an object which encapsulates the geometric bounds of the object: the upper left and lower right corner positions.

Categories