Skip to main content
Participating Frequently
January 14, 2011
Question

Obtaining coordinates and dimensions of page items using .NET and IDML.

  • January 14, 2011
  • 2 replies
  • 824 views

I'll preface this by saying that I am extremely new to Adobe software.

I have been assigned a task that requires me to obtain the coordinates and dimensions of all TextFrames in an InDesign document.  I need to have these coordinates in an x,y format.

Essentially what I want to be able to do is identify where these page items are, in universal terms.  I have read the relevant sections of the IDML spec, and searched through post after post, but I'm still not quite getting it.

For a TextFrame, the height and width are easy.  It's the coordinates that are blowing my mind.  I've gotten far enough to know that I need to calculate based off of the item's ItemTransform attribute, but I am just not sure what to do with it.  I feel like I'm missing a couple of basic points.  Any and all help is most appreciated.

Thanks


This topic has been closed for replies.

2 replies

Inspiring
January 17, 2011

Actually I meant the geometric bounds property of your text frame.

For example in JavaScript this works

$.writeln(app.activeDocument.textFrames.item(0).geometricBounds);

In .NET the property names are constructed slightly different.

AgsmithMSAuthor
Participating Frequently
January 17, 2011

I do not see that property in the IDML.

The Page has a GeometricBounds property, but none of the page's items do.

Inspiring
January 17, 2011

Yes, you're right with IDML, while your post also mentioned you were using .NET .

The script languages differ in a few details, this is one of them.

Dirk

Inspiring
January 14, 2011

.NET goes thru the scripting interface, and IDML is basically an XML representation of the same.

Scripting topics are better discussed next door, in the scripting forum.

Transformations take time to get used, I learned the basics from the postscript language reference or later the PDF reference books (both are available as free downloads at the Adobe site) and the scripting side is very scientifically correct / out of the world. For a down to earth approximation that disregards all rotation, shear and so forth, use the geometric bounds - just take them relative to the page.

Dirk

AgsmithMSAuthor
Participating Frequently
January 17, 2011

Thanks to Dirk's nudge, I believe I have figured this out.

What I am doing is adding tx and ty to the four anchor pathpoints.  That gives me the coordinates of the page item.  To further simplify things, I am then subtracting the page's tx and ty.  This moves the origin from the center of the page to the top left corner.

The end result is a list of coordinate sets that can be consumed by all the other stuff I haven't written yet.